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

Kevin Smith khs4473 at gmail.com
Sat Jan 5 05:34:14 PST 2013


>
> That's not true. It's still more work to spec ?. as well as refutable
> destructuring for ES6. It requires an internal Nil (or Reference variation
> as Allen suggested to me). It requires grammar hassling to allow suffix-?
> in expressions.


I see that.  Bear with me nonetheless.

It seems that on both the pattern side and the expression side, we're
trying to express the same thing: an "irrefutable property get", where we
get a nillish reference if the property does not exist.  Moreover, I assert
that this is exactly what we want on the expression side, nothing more or
less(*).

We know that we're going to want to expose this "irrefutable property get"
on both the pattern side and the expression side at *some* point.  We also
know that we want to use the "?" sigil to indicate this operation.

The syntax question is whether we use suffix-? (where the "?" appears after
the property name) or prefix-? (where the "?" appears before the property
name).

(Prefix-? on the expression side means that ".?" is a single lexeme.)

Using suffix-? on the expression side is not backward compatible for the
ASI reasons already mentioned:

    a.b?
    c:
    d;

So we're down to two possibilities:

1) Expression: prefix-?, Pattern: suffix-?
2) Expression: prefix-? Pattern: prefix-?

Consistency would seem to dictate (1).

    { p: { ?q: v } } = o;
    v = o.p.?q;

But in any case, the "irrefutable property get" operation has to be
specified, so given my assertion above (*) it boils down to just deciding
this prefix or suffix question.

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


More information about the es-discuss mailing list