-
Notifications
You must be signed in to change notification settings - Fork 23
Change operator to ||| and reserve ?? for optional chaining #17
Comments
I'm floating this syntax option with the committee today, so we'll see. |
If use |
@hax the 3 optional chaining operators will always need to be consistent within themselves. |
FWIW I would intuit The |
@ljharb I know. I just point out that the only reason someone prefer |
That’s not the only reason; aesthetics and overloaded meanings come into play as well. |
@ljharb Yeah I believe there are always other reasons. But it seems in previous discussions "the other reasons" for "??." were not mentioned much. Maybe I missed some. In fact I always try to find the real reasons behind aesthetics, include |
Yes! I was just thinking this independently, especially in light of tc39/proposal-optional-chaining#48 I'm glad someone else has already thought of this. It also gives the language enough syntax flexibility to add maybe a nullish |
In the same way that |
Repeating my comment here: in the TC39 meeting this week it was brought up that if |
Repeating my response here about the word 'stricter' not being a comprehensive enough definition from one data point. This is still the best and most intuitive syntax by a long shot. Fewer keystroke, less characters to remember, easier to learn, easier to understand.
original source: tc39/proposal-optional-chaining#48 (comment) |
What matters is whether the couple |
In my PHP codebase, I have some occurrences of |
Repeating my comment here: I think we should learn from failure of visually too close operators. The mainstream coding style now only allow Note we can forbidden |
I don't understand the rationale for A stricter |
This seems answered; the feature is stage 4; I think this can be closed. |
As the form
x || defaultValue
is a widely known pattern for javascript developers, a natural and more intuitive operator for this proposal would therefore rather be|||
(three pipe-signs instead of two). This goes in line with the relation between the===
and==
operators.Going this direction would also also free up the
??
operator to be used for optional chaining, which is discussed hereSample
The text was updated successfully, but these errors were encountered: