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

Brandon Benvie brandon at brandonbenvie.com
Wed Jan 2 10:43:09 PST 2013


For comparison, here's the internal methods that I currently have
implemented, which line up with what you said.
https://github.com/Benvie/continuum/blob/gh-pages/engine/object-model/%24Nil.js#L105


On Wed, Jan 2, 2013 at 1:28 PM, Herby Vojčík <herby at mailbox.sk> wrote:

>
>
> 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
>>> asked in this thread, unless I did not understand).
>>>
>>
>> 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
>
> ______________________________**_________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/**listinfo/es-discuss<https://mail.mozilla.org/listinfo/es-discuss>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130102/5a96a9c6/attachment.html>


More information about the es-discuss mailing list