On Thu, Jun 21, 2012 at 11:23 AM, Brendan Eich <[email protected]> wrote:

> John Tamplin wrote:
>
>> So do you have to do it by treating the ?. operator as a standalone?
>>
> Not sure what you mean here -- "standalone ?" (with an English-langauge ?
> implied after in your sentence? ;-)?
>
> Or something else that amounts to a concealed Reference or Nil-value-proxy
> expression?
>
> Just talking spec here: as Allen mentioned, ECMA-262 specifies semantics
> by evaluating productions in a mostly-LR(1) grammar, so member and call
> expressions (left-associative) have to result in some kind of
> (spec-internal or language-external) value.
>
> Thus foo?.bar.baz.quux is really (((foo?.bar).baz).quux).


Yes, and I am suggesting during parsing it gets treated as:

(((foo?.bar)?.baz)?.quux)

because we saw a ?. operator earlier in the expression.  That way you don't
have to get the Coffeescript behavior by introducing some fake object or a
MaybeReference, and you just implement the ?. operator as always returning
the LHS if it is null/undef.


> Indeed one can translate when parsing. CoffeeScript does this, with some
> separate passes for its other purposes (implicitly declared variables,
> indentation-based block structure, etc.).
>
> The ES specs can't do this, though, not without a total rewrite.


I realize it would be changes, but then so would adding a MaybeReference.
 Just thought I would bring it up.

-- 
John A. Tamplin
Software Engineer (GWT), Google
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to