On Nov 7, 2011, at 8:23 AM, Andreas Rossberg wrote:
> On 7 November 2011 17:07, Allen Wirfs-Brock <[email protected]> wrote:
>>> let {x} = 666
>>>
>>> which will be refuted, by raising a TypeError.
>>
>> No,
>>
>> It does ToObject(666) and then looks for the "x" property of the resulting
>> wrapper object.
>
> Ouch, really? I don't see that in the proposal
> (http://wiki.ecmascript.org/doku.php?id=harmony:destructuring), and to
> be honest, it sounds like a horrible idea.
Proposal typically don't cover this level of detail. These are the sort of
things that we have to sort out when I write the specification and it's why I
bring them up here.
> It is just another way to
> silently inject an `undefined' that is tedious to track down. We
> already have too many of those...
It is how the language currently behaves in all situations where an object is
needed but a primitive values is provided. We want consistency in language
design, not a hodgepodge of special cases and different rules.
>
> When would this ever be useful behaviour instead of just obfuscating bugs?
let {toFixed, toExponential} = 42;
Allen
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss