Existential Operator / Null Propagation Operator
brendan at mozilla.org
Tue Apr 7 21:52:34 UTC 2015
Brendan Eich wrote:
> Caitlin Potter wrote:
>> 6, 2015 at 5:42 PM, Brendan Eich<brendan at mozilla.org
>> <https://mail.mozilla.org/listinfo/es-discuss>> wrote:
>> >>/ Did you keep backward compatibility? `x?.1:y` must continue to
>> >This is why I suggested a leading operator (`?a.?b()`) because it
>> >like it would have the least potential for conflict with existing valid
>> What about something like
>> MemberExpression[?Yield] ?|.| IdentifierName
>> MemberExpression[?Yield] ?*[* Expression[In, ?Yield] |]|
>> Context specific to MemberExpressions, as far as I'm aware there's no
>> otherwise valid ternary expression that could be mixed up for it, and
>> it wouldn't need a cover grammar?
> We can try being this precise, as you say -- but we cannot then handle
> x?(y) as CoffeeScript does. Instead of being neither fish nor fowl,
> better to be fowl with leading ?, or use a distinct and regular syntax
> that handles all the cases we want. My two cents,
Worse, we can't even do ?[ as you propose with LR(1) or any similar
approach. Here's a bison toy grammar:
| E ',' A
| M '=' A
: M '?' A ':' A
M: M '[' E ']'
| M '?' '[' E ']'
| '(' E ')'
| '[' E ']'
(P for Primary, M for Member, C for Conditional, A for Assignment.)
The reduce/reduce conflict recognizing a left sentential form '[' E ']'
vs. M '?' '[' E ']' shows the fatal ambiguity.
More information about the es-discuss