On Apr 18, 2012, at 1:45 PM, Herby Vojčík wrote:

> Brendan Eich wrote:
>> Allen Wirfs-Brock wrote:
>>>> 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.
>> 
>> Of course, one could destructure like so:
>> 
>> let {0: b, 0: {x, y}} = ...;
>> 
>> 
>>> 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).
>> 
>> Destructuring patterns should be static. I don't see a conflict if we
>> stick to this rule, but given the ability to use an object pattern, I
>> don't see a need for the array literal element label syntax either.
> 
> As was already pointed out, problems are not only _array_ destructurings, but 
> more argument list destructrings, where if you want to destructure 0-th 
> argument both as b and as {x,y}, you would need something like that, since 
> you already are inside list, you cannot opt for object.


function f({b},...rest) {
   let {x,y}=b;
   ...
}

doesn't seem like too much of a burden


> 
> (but if it is not the problem, I'd gladly see at least the object 
> double-destructure-same-field in ES6. It is not violating the "no double 
> property names" of strict mode since the assignment goes the other way)

It's in the spec. draft.  There aren't actually object literals so the 
duplicate property name rules don't apply.  It's the duplicate lexical binding 
rules that are in play, but only on the target names, not the property 
selectors.

Allen


_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to