On Apr 18, 2012, at 9:29 AM, Brendan Eich wrote:

> Herby Vojčík wrote:
>> Herby Vojčík wrote:
>>> 
>>> Maybe allowing
>>> let {b, b:{x,y}} = obj;
>>> would be enough. It sort-of comforms to existing syntax as well as
>>> semantics.
>> 
>> BTW, if you use var instead of let, if already works out of the box (in FF11 
>> firebug console; just tried), so why include as if it already is there, 
>> albeit in different form? 
> 
> We implemented destructuring years ago to implementor- and user-test ES4 
> proposals. They did not forbid duplicates. That's all.
> 
> Nothing normative in experimental Firefox implementation features, of course. 
> You cite them as "already [there]" and that's true but it doesn't govern what 
> goes into ES6.

But is also works this way according to the ES6 draft spec.  It works with var 
because var allows duplicated declarations:

   var a=1;
   var a=2;
   var a=3;

which, from a declaration perspective isn't really any different from 
   var a=1,a=2,a=3;

However let/const does not:

{   //block level duplicate declaration early error
   let b=1;
   let b=2;
}

or just
  let b=1,b=2 ;   //block level duplicate declaration error

var {b,b:{x,y}} = obj;  //fine because var declaration static semantics don't 
disallow duplicates
{  //avoid any conflicts with the preceeding var
   let {b,b:{x,y}} = obj;  //block level duplicate declaration
}

You might argue that the second b in the destructuring isn't actually 
introducing a binding for b.  However,  syntactically it looks like one and 
that is what the static semantic rule is driven off of.  If we allow that, we 
would also be allowing:
    let b=somethingElse;
    let {b:{x,y})=obj;

If we want to allow that I'll have to some up with a different way to specify 
the static semantics.

Allen

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

Reply via email to