On Nov 20, 2011, at 2:24 PM, Brendan Eich wrote:
> On Nov 20, 2011, at 11:16 AM, Allen Wirfs-Brock wrote:
>
>> Actually, I think you would want to say:
>>
>> function frob(arg1, arg2, {foo = defFoo, bar = defBar, baz = defBaz}={}) {
>
> Thanks.
>
>
>> It may be that for destructuring, in general, we want to treat a
>> null/undefined RHS as { }. Eg:
>>
>> let {a=1,b=2,c=3} = undefined;
>> //should this throw or should this be the same as:
>> let {a=1,b=2,c=3} = { };
>
> I would not add more implicit magic to JS. E4X had junk like this in it,
> which only ever concealed bugs.
I'm of two minds about this. In the abstract, I agree with Brendan; fail-soft
conceals bugs. But in reality, our destructuring logic is incredible fail-soft.
Hardly anything in destructuring is treated as an error. And the syntax really
*wants* to match the common pattern. So I'm torn.
Dave
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss