New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elvis/existential operator? #855

Closed
naholyr opened this Issue Feb 21, 2015 · 10 comments

Comments

Projects
None yet
9 participants
@naholyr
Copy link

naholyr commented Feb 21, 2015

I know this is out of spec, but it would be very nice to add support for Elvis operator in playground.

object?.property // object && object.property
foo?() // foo && foo() 
@naholyr

This comment has been minimized.

Copy link

naholyr commented Feb 21, 2015

I'll try to make a PR but I'm afraid the learning curve before contributing is a bit high yet ^^

@kittens kittens added the duplicate label Feb 21, 2015

@kittens

This comment has been minimized.

Copy link
Contributor

kittens commented Feb 21, 2015

Duplicate of babel/acorn-babel#9. Happy for this to be submitted via a PR, a good reference would be @jridgewell's addition of the "mallet operator" via babel/acorn-babel#17 and #516. Thanks!

@kittens kittens closed this Feb 21, 2015

@chocolateboy

This comment has been minimized.

Copy link
Contributor

chocolateboy commented Feb 22, 2015

@naholyr FYI: the safe navigation operator and the Elvis operator are not the same:

Safe navigation operator

foo?.bar?.baz

Elvis operator

foo ?: bar

P.S. If the sweet.js interop plans ever come to fruition, the latter (haven't tried the former) is quite easy to implement in sweet.js.

@naholyr

This comment has been minimized.

Copy link

naholyr commented Feb 22, 2015

Yep, my bad for the name. Don't open issues or PR too late when too tired
:P it's been discussed as "existential operator" in es6 but never drafted
if I remember well

Le dim. 22 févr. 2015 17:54, chocolateboy notifications@github.com a
écrit :

@naholyr https://github.com/naholyr FYI: the safe navigation operator
and the Elvis operator are not the same:
Safe navigation operator
http://groovy.codehaus.org/Operators#Operators-SafeNavigationOperator(?.)

foo?.bar?.baz

Elvis operator
http://groovy.codehaus.org/Operators#Operators-ElvisOperator(?:)

foo ?: bar

P.S. If the sweet.js interop
#568 (comment) plans
ever come to fruition, the latter (haven't tried the former) is quite easy
to implement in sweet.js
https://gist.github.com/chocolateboy/67226b9bc0c948c1f1de.


Reply to this email directly or view it on GitHub
#855 (comment).

@lolmaus

This comment has been minimized.

Copy link

lolmaus commented Jul 27, 2015

What's the status on this? The reference to babel/acorn-babel#9 is broken.

@Erid

This comment has been minimized.

Copy link

Erid commented Aug 20, 2015

The ES draft is still being discussed and I think there's no implementation of the existential operator yet on Babel, I believe the best road would be to build a plugin... The plugin documentation is a WIP though, but maybe with some help we can manage to build one.

@jmm

This comment has been minimized.

Copy link
Member

jmm commented Aug 20, 2015

@lolmaus @Erid This is not coming to babel per se, and it's not possible to do it via plugin right now because it would require access to the parsing phase and plugins only have access to the transformation phase. That may happen eventually, but it's not slated for the next major (see #2168 "syntax extensions"). If this ever became standardized it would be implemented via plugin (an "official" one or otherwise), because by then all transformers will be out of babel core. See also https://esdiscuss.org/topic/existential-operator-null-propagation-operator.

@bramus

This comment has been minimized.

Copy link

bramus commented Jan 30, 2017

Earlier today/this week this feature – named “Null Propgation Operator” – was promoted to stage-1 by the TC39 Committee.

I guess that makes this request re-open for consideration?

@xtuc

This comment has been minimized.

Copy link
Member

xtuc commented Jan 31, 2017

@bramus there is already babel/babylon#328.

@hzoo

This comment has been minimized.

Copy link
Member

hzoo commented Jun 28, 2017

merged #5813 (will be in the next v7 alpha release)

@babel babel locked and limited conversation to collaborators Jun 28, 2017

@hzoo hzoo added the outdated label Jul 10, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.