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

Kevin Smith khs4473 at gmail.com
Tue Jan 8 20:10:03 PST 2013


I was worried that a suffix "?" in the pattern language might be
future-hostile to an existential operator or existential member operator,
owing to the fact that suffix "?" is grammatically a bit sketchy on the
expression side (in my mind, anyway).

But I think I'm satisfied now.  Basically, I don't think that an
existential operator is all that important to have, because:

1) Pattern matching via a match statement or expression is far more
powerful, and would subsume much of the use case for an existential
operator.

2) It may be that what we really want for the non-match use case isn't an
existential operator, but something more like a unary "try path" operator.
 To extend the example from the CoffeeScript docs, something along these
lines:

    let zip = select lottery.draw().winners[0].address.zipcode;

Where "select" is a context-sensitive keyword and the select expression
modifies the behavior of its child member expressions such that instead of
throwing TypeErrors when the object is null or undefined, they evaluate to
a "nillish" reference.

Just a thought...

{ Kevin }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130108/2928a536/attachment.html>


More information about the es-discuss mailing list