Open MadProbe opened 3 years ago
This doesn't seem ambiguous to me. The first ternary is cond ? (null::example) : get()
, the second is a syntax error.
As to your suggestion, remember that 1.
is legal syntax:
const ? 1.:get()
I think we could parse .: only when \<value>::\<symbol> pattern is encountered and your example functions as it is now, and
1 ? 1..:1
is a syntax error
Is null::example:get()
a valid expression at all? Seems like it would have to be a valid expression all by itself for it to be a problem with ternaries.
@MadProbe This issue already be listed in the docs (https://github.com/tc39/proposal-extensions/blob/master/docs/syntax.md#syntax-ambiguity-of-abc) though I'm sorry it not listed in the repo readme page.
There are many possible solutions, .:
may work, but as the author of this proposal I insist that, if we really want change token, it should be only one character. The doc I mentioned list all possible chars, and consider other factors, the alternatives are:
o::Ext~method()
o::Ext#method()
o::Ext'method()
(to be honest, I slightly prefer this 😅)Is
null::example:get()
a valid expression at all? Seems like it would have to be a valid expression all by itself for it to be a problem with ternaries.
@justinmchase Yes, it's valid. It just use null
as receiver and send to example
. Basically null::example:get(...args)
is just the syntax sugar of Extension.from(example).invoke(null, 'get', args)
.
(To avoid this hazard i think we can change ':' ext name operator to '.:', which seems to have no hazard at all)