destructuring: as patterns?

Allen Wirfs-Brock allen at wirfs-brock.com
Wed Apr 18 12:27:32 PDT 2012


On Apr 18, 2012, at 11:42 AM, Brendan Eich wrote:

> Allen Wirfs-Brock wrote:
>> False alarm! Actually the above isn't correct.  The current spec draft actually does allow
>>   let {b,b:{x,y}};
> 
> Nice -- is this sufficient to avoid 'as'?
> 
> For array patterns we would need to allow property assignments in array literals:
> 
>  let [b, 0:{x,y}];
> 
> This was proposed at one point, IIRC, but a while ago.

It was also suggested that we allow iterators/generators to supply the  initialization values to array destructurings.  This currently isn't in the draft spec. and I think it would introduce some fairly significant specification and practical complications (eg, rest bindings and open-ended generators).

However, the reason I bring it up it that if we ever do want to add that sort of generative initialization value feature, it would seem to have significant interactions with the explicit array property designator feature shown above.  The most future proof thing for right now would be to do neither.

Allen







> 
> /be
> 



More information about the es-discuss mailing list