ES6 doesn't need opt-in

Allen Wirfs-Brock allen at wirfs-brock.com
Tue Jan 3 16:38:46 PST 2012


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> ]

It's a grammar bug.  Thanks for the proof reading...

Allen




> 
> 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;
> 
> As such, the example you give could only be storing y to a property x of object let (or a syntax error in ES5-strict / ES6 modes).
> 
> Is my reading of the spec incorrect here?  Is this the intention?
> 
> cheers,
> G.
> 
> 
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
> 



More information about the es-discuss mailing list