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

Herby Vojčík herby at mailbox.sk
Wed Jan 2 13:30:13 PST 2013



Brendan Eich wrote:
> Brendan Eich wrote:
>> Yes, I already agreed (three times :-|) that nil rescues ?. from the
>> condemnation ARB heaped on the CoffeeScript semantics.
>>
>> That's not relevant to what we were just arguing about though: whether
>> nil rather than undefined should be an observable result of either
>> destructuring or (you seemed to say just above) property gets on plain
>> old objects!
>
> Apologies, I did not make the full idea clear:
>
> You want nil in the language and observable via desugaring
>
> o.?p.q ==> (o.p == null ? nil : o.p).q
>
> without re-evaluating o.p of course (and using the syntax you showed).
> Furthermore, in the case where o.p == null, the result is nil.q which is
> nil.
>
> (Please correct me if I am wrong on any of this! Appreciate the
> discussion here.)

No, now it is exactly how it was meant.

> What I would like to do: spec ?. without exposing nil. Perhaps this is
> not possible but I think it is, since we can make the definite semantics
> for o.?p.q or whatever syntax we want (I advocate o.p?.q) do a final
> censoring act that converts nil back to undefined.
>
> You could be right that we want nil and ?. together -- no way to
> decouple risk. I'm not seeing that argument yet. People want ?.
> yesterday, nil not so much (see twitter).
>
> /be
>
>


More information about the es-discuss mailing list