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

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

```
Brendan Eich wrote:
> Herby Vojčík wrote:
>> Brendan Eich wrote:
>>> I like Nil, and it may help rescue ?. the existential operator strawman.
>>> But that is in the expression language, not in the pattern language.
>>
>> I like not to make things unnecessarily disjoint. Here I see the
>> possibility of having pattern language (in future patterns as well as
>> in present destructuring) having same semantics as the expression
>> language _with_throwing_on_nonexistent_property_ (that is what you
>
> I'm with you on wanting equivalences, such that "same semantics" works
> up to some limit (proxies, perhaps -- I'm not sure). Since
> pattern-matching is in the future it is possible it could diverge
> observably from equivalent expression language, for good reason.
>
> If there's no reason in the future to diverge, great.

In the short example you sketched, with case {must, ?may} there is no
need to diverge from the destructuring; so I did not even imagine such
divergence for the moment.

> We need to detail how Nil works, how it cannot be wrapped or observed,
> etc. in order to maintain equivalence.

In my naive view, [[GetP]] returns Nil, [[SetP]] does nothing, [[Call]]
return Nil. But there are sure some nasty details down there.

>> That is, these are identical, except the syntax:
>>
>> r = o.p.q {p: {q: r}} = o
>> r = o.?p.q {?p: {q: r}} = o
>> P=o.p; Q=o.?q {p: P, ?q: Q} = o
>
> Here I part company only on syntax:
>
> r = o?.p.q {p?: {q: r}} = o
> P=o.p; Q=o?.q {p: P, q?: Q} = o
>
> And of course, the short-hand works:
>
> p=o.p; q=o?.q {p, q?} = o

Well, if it must be this way. I mentally joined the ? with the dot where
the operation occurs... but now that I think of it, it doesn't matter if
it is "take o, take its p and make it Nil if nonexistent, take its q"
early nilling of mine and "take o, take its p, make it Nil if null&Co.,
take its q" postponed nilling of yours.

I feared it could make mental errors, but it will not.

>> With "it can go deeper, since it is Nil" I meant the second line,
>> where (o.?p) produces Nil, so o.?p.q being Nil.q produces Nil as well,
>> without throw.
>
> Yes, I agree (already :-P) that this is a good idea for saving the
> existential operator.
>
> /be

Herby
```