Assignment to method invocation result

Jussi Kalliokoski jussi.kalliokoski at gmail.com
Fri May 16 03:27:09 PDT 2014


On Thu, May 15, 2014 at 9:17 PM, Rick Waldron <waldron.rick at gmail.com>wrote:

> This particular syntax would also require static (a lookahead) and
> semantic (based on the lookahead results) disambiguation to account for
> DecimalLiteral:
>
>   var n = .2;
>

True. However, it's a good thing valid identifiers can't start with a
number, otherwise even lookahead couldn't save it. :P


>
>
> If the "." was on the other side?
>
>   AccessorAssignmentOperator :
>     .= IdentifierName
>

I deliberately avoided that because I've seen it proposed for
Object.extend() syntactic sugar a couple of times:

foo .= {
    bar: 1
};

( proposed as doing roughly the same as `_.extend(foo, { bar: 1 });` )

But I have no personal preference either way.


>   var string = "  a  ";
>   string .= trim(); // would throw if no `trim` method existed for `string`
>
>   string; // "a";
>
>
> Where ".=" means assign the result of "Property Accessors Runtime
> Semantics Evaluation" with lval and rval in appropriate positions (TBH, I'm
> sure I missed something in there)
>
>
> Rick
>
>
- Jussi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140516/43c87d81/attachment.html>


More information about the es-discuss mailing list