fail-fast object destructuring (don't add more slop to sloppy mode)

Brendan Eich brendan at mozilla.com
Sun Jan 6 15:24:57 PST 2013


Kevin Smith wrote:
>
>
>     Would we?  This is something a little different than "irrefutable
>     property get".  Thinking...
>
>
> Notice that, strictly speaking, we don't need an "irrefutable object" 
> operation:
>
>     let v = ?o.p;
>
>     // is equivalent to:
>     let v = {o}.?o.p;
>
> The allocation in "{o}" can be statically optimized away.
>
> The same goes for the pattern language:
>
>     let ?{ p: v } = o;
>
>     // is equivalent to:
>     let { ?o: { p: v } } = {o};

Sure, but that's crying out for a shorter form that avoids repeating o. 
Note also that in the expression language, |o| might be a longer 
expression (even, gasp, with embedded effects) that you would not want 
to repeat.

Whatever we do for existential operators, destructuring in ES6 with 
refutable-by-default patterns wants something at all levels, including 
outermost -- or so I argue.

/be


More information about the es-discuss mailing list