Optional Chaining (aka Existential Operator, Null Propagation)
concavelenz at gmail.com
Mon Feb 8 18:58:22 UTC 2016
If we ever hope to include "elvis".
would be roughly equivalent to:
obj != null ? obj : [expr]
rather than what you are suggesting here:
obj != null ? obj[expr] : undefined;
On Sun, Feb 7, 2016 at 4:16 PM, Bergi <a.d.bergi at web.de> wrote:
> Claude Pache wrote:
>> Yes, that syntax is possible. Whether it is preferable is a question of
>> taste. Personally, I don’t like it:
>> * I slightly prefer `?.` over `.?` for the following reason: The `?.`
>> token may be conceptually separated in two, first the question mark which
>> checks whether the expression at its left evaluates to null/undefined (and
>> orders to stop processing if it is the case); then the dot which proceeds
>> with property lookup.
> Totally agreed.
> * I find that the question mark inside the brackets is out of place, as it
>> isn’t part of the arguments (for function call) or of the expression
>> defining the key (for property access).
> I agree here as well, it does feel out of place, and `?[…]`/`?(…)` would
> feel a lot more natural. Given that those are not feasible for parsing
> however, I would still prefer them
> func(? …args)
> new C(? …args)
> over the proposed alternative
> new C?.(…args)
> where the placement of the dot is just horrifying my eyes.
> Maybe we could at least use some other character instead of the dot?
> new C?:(…args)
> might bear too much resemblance to the ternary, but imo the colon fits
> better than the dot here.
> es-discuss mailing list
> es-discuss at mozilla.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss