The Existential Operator

Brendan Eich brendan at mozilla.org
Tue May 20 09:36:00 PDT 2014


Dmitry Soshnikov wrote:
> Will the "Existential Operator" for properly accessors be something 
> interesting to consider for ES7 spec? Currently CoffeeScript uses it well.

Please see

http://esdiscuss.org/topic/sept-18-tc39-meeting-notes#content-2

and find "ARB: This is non-compositional". Citing text for reader 
convenience:


  Existential Operator (strawman discussion)

(Presented by Brendan Eich, Mozilla)

Significant desire include a null and undefined check in syntax/operator 
form (a la coffeescipt)

|     o = {}
     r = o?.p.q.r
     r = o?.p?.q.r
|

Mixed discussion about the needs and use cases as they apply to 
coffeescript code.

ARB: This is non-compositional

|     o = {}
     r = o?.p.q.r
     r = (o?.p).q.r
     r = o?.p.q.r()
|

Results in…

|     var o, r;
     o = {};
     r = o != null ? o.p.q.r : void 0;
     r = (o != null ? o.p : void 0).q.r;
     r = o != null ? o.p.q.r() : void 0;
|

Non-starter.

DH: Why not an operator that needs to be explicit?

|     o?.p?.q?.r
|

LH: Why would you ever even use it on the first?

BE: Forget all of the problems with coffeescript's impl, the need exists.

YK: In the common cases, where it works, it works well. Where it 
doesn't, it falls apart unexpectedly.

WH: What about other contexts such as p?[x], p?.q[x], and p?(x) ? [Note 
that grammar problems arise for some of those.]

General agreement.

*Conclusion/Resolution* Seems useful, but not now. Semantics are unclear

---

The notes ended a bit too optimistically in my view! "Non-starter".

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


More information about the es-discuss mailing list