On Jan 3, 2012, at 4:31 PM, Gavin Barraclough wrote:

> On Jan 3, 2012, at 3:27 PM, Brendan Eich wrote:
> 
>> You're proposing that we require 'let' be only at the start of statements? 
>> If so, then destructuring is problematic:
>> 
>>  foo();
>>  let [x] = y;
>> 
>> Did that last line destructure the property named '0' of the object denoted 
>> by y into a let-bound x, or was it old, pre-ES6 code that stored y into the 
>> x'th element of an object denoted 'let'? In either case the 'let' is at the 
>> start of a statement.
>> 
>> /be
> 
> Based on the draft of the spec I have, I don't think that is an actual 
> ambiguity here (albeit naming an array 'let' could be very confusing!).
> This could of course either be an error in my reading of the spec, or a bug 
> in the current draft of the grammar. :-)
> 
> The rules for destructuring give:
> 
> ArrayBindingPattern :
>       [ Elision<opt> BindingRestElement<opt> ]
>       [ BindingElementList , Elision<opt> BindingRestElement<opt> ]
> 
> Note the literal comma required after any BindingElementList - as I parse the 
> grammar your example is not valid ES6, to destructure the first element from 
> an array you would have to write:
> 
>  foo();
>  let [x,] = y;

No, the grammar is based on ArrayLiteral and produces the same "shapes", just 
with identifiers in the value positions. See the first right-hand side, 
interpreted with no Elision but with a BindingRestElement (which produces 
BindingIdentifier).


/be
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to