An array destructing specification choice
Brendan Eich
brendan at mozilla.com
Mon Nov 7 13:39:50 PST 2011
On Nov 7, 2011, at 2:18 AM, Andreas Rossberg wrote:
> On 5 November 2011 17:44, Brendan Eich <brendan at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20111107/82f629de/attachment.html>
More information about the es-discuss
mailing list