> Le 4 févr. 2016 à 17:47, John Lenz <concavel...@gmail.com> a écrit :
> 
> 
> [...]
> 
> Waldemar's example makes the problem obvious but I think we could do use, 
> which I think is preferable to the proposed:
> 
> .?
> (?)
> [?]

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.

* 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).

>  
> [...]
>  
> yes, I meant the equivalent to:
> 
> x ?: value
> x == null ? x : value

I assume you meant: `x != null ? x : value`

Note that this is a completely different operator. For the proposed optional 
chaining operator, we stop processing when the LHS is null/undefined; while for 
the `?:` null-coalescing operator, it is the other way round. Also, the 
precedence is not the same.

I have wilfully restricted the scope of my proposal to optional chaining only, 
because of its intrinsic technical complexity.

—Claude
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to