On Nov 7, 2011, at 2:18 AM, Andreas Rossberg wrote:

> On 5 November 2011 17:44, Brendan Eich <bren...@mozilla.com> wrote:
>> Destructuring is "irrefutable" in that it desugars to assignments from 
>> properties of the RHS. It is not typed; it is not refutable
> 
> I don't think that's true, at least not in the usual sense of
> "irrefutable pattern". Because you can write
> 
>  let {x} = 666
> 
> which will be refuted, by raising a TypeError.

Nope. You get undefined. That's why it's irrefutable -- you can't build 
refutable matching on this (you'd need an OOB value other than undefined, or 
exceptions).

js> let {x} = 666
js> x
js> 


> Of course, the real question is, what does this do:
> 
>  let {} = 666

No-op. We worked this out for ES4, I had originally made it an early error, but 
Lars Hansen argued for the 0-identifier basis case:

js> let {} = 666
js> 

This can simplify code generators slightly. It's not a big deal but I agree 
with Lars, there should be no error case here.

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

Reply via email to