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

Herby Vojčík herby at mailbox.sk
Wed Jan 2 12:10:49 PST 2013



Brendan Eich wrote:
> Kevin Smith wrote:
>>
>> Interpreted this way, any additional irrefutable markers in a
>> subtree under a refutable identifier become redundant, correct?
>>
>>
>> Er, meant this:
>>
>> Interpreted this way, any additional irrefutable markers in a subtree
>> under an _irrefutable_ identifier become redundant, correct?
>
> For the proposal to use Nil for the expression semantics, yes.
>
> You're right, this implies destructuring binding forms behave in a way
> that I flagged as possibly not wanted:
>
> let {p?: {q: r}} = o;
>
> would bind r to undefined for any o that doesn't have a p or that does

In my view it binds to Nil (but it is falsey, == null etc., typeof 
'undefined' so it should work).

> but o.p doesn't have a q.
>
> On second look this is not as bad as I thought. It would be bad if r
> were not bound (so an outer r could become visible) depending on o's
> dynamics. That seems right out!
>
> /be
>>
>>
>> r = o?.p?.q { p?: { q?: r } } = o
>>
>> Using Nil, the "q" in all cases is "present" (evaluating to Nil),
>> so the "?" in "q?" has no effect. Is that right?
>>
>>


More information about the es-discuss mailing list