Existential operator (was: ||= is much needed?)

Allen Wirfs-Brock allen at wirfs-brock.com
Tue Jun 19 14:31:16 PDT 2012

On Jun 19, 2012, at 2:15 PM, Jeremy Ashkenas wrote:

> On Tue, Jun 19, 2012 at 4:35 PM, Allen Wirfs-Brock <allen at wirfs-brock.com> wrote:
> ...
> Ha ha, loose equality strikes again! It's actually guarding for both null and undefined. It's the only place that CoffeeScript purposefully uses the in-all-other-cases-avoided != operator. undefined == null, right?

Of course! I'm blind to it because I always try to be explicit and use === tests...

> Ah, again.  I don't think Brendan's strawman will produce that result.  The ...?.i is going to get undefined when it does GetValue on the Reference produced for object.property.  Then undefined.can will throw in step 5 of 11.2.1 because the LHS is undefined.  Getting this behavior seems to requires modifying . as well as defining ?. 
> I'm afraid I can't speak to the spec language or strawman ... but the basic idea with soaking is to short-circuit evaluation as soon as the soak fails. In the same way that:

The ES spec. is left recursive so the semantics for 
   MemberExpression :: MemberExpression . IdentifierName

has no direct way of knowing that the MemberExpression to the left of the . contained a ?.   
Similarly if that nested  MemberExpression was:
   MemberExpression :: MemberExpression ?. IdentifierName
it has no direct way (other than throwing an exception) to terminate evaluation of the MemberExpression to its right.  That is why things like Reference values are used within the specification to transport semantic state around.  Of course an actual implementation is not necessarily limited in this manner...


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120619/eefcf3cb/attachment.html>

More information about the es-discuss mailing list