fail-fast object destructuring

Andreas Rossberg rossberg at google.com
Thu Jul 5 09:51:56 PDT 2012


On 4 July 2012 17:01, Brendan Eich <brendan at mozilla.org> wrote:

> I understand that motivation, but was trying to point out that it is
>> merely one under several (conflicting) potential equivalences to consider.
>> For example, in languages with pattern matching I usually have
>>
>>   let pat = exp; stats
>>   ~=
>>   match (exp) { case pat: stats }
>>
>> (Assuming a match without a default throws, otherwise add an explicit
>> error default.)
>>
>> IMHO this equivalence would be much more important, because it is
>> necessary for giving a uniform meaning to patterns per se.
>>
>
> If only JS had pattern matching!
>
> We may add pattern matching, but does that future possibility make the
> equivalence you cite more important than the one JS programmers might
> expect today?
>

Well, note my careful use of the conjunctive. :)  That basically was the
question I initially asked. My viewpoint is: If there is some reasonable
chance that we might add pattern matching at some point in the future, then
yes, I think we should not be future hostile, and bear that equivalence in
mind as important.


> We could try to have our cake and eat it, by extending the pattern
> language with prefix-! or prefix-?. Which prefix depends on the choice of
> default behavior, based on ranking of the two equivalences. Whatever that
> ranking, does this make sense so far?


Sure, I'm all for that. As long as they -- and the rest of the pattern
language -- have the same meaning in all contexts.

/Andreas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120705/3ebdc6bc/attachment.html>


More information about the es-discuss mailing list