Quantcast
Channel: Why can't "?" be used in variable or function names
Viewing all articles
Browse latest Browse all 12

Why can't "?" be used in variable or function names

$
0
0

It isn't because no-one proposed it.
If proposed, it would introduce an ambiguity with the ternary ( ? : ) operator.

E.g., what does

f?
g?h:i;

mean?

Is it the same as

f ? g?h : i;  // ternary operator where `g?h` is a single ident

or with semicolon insertion the same as

f?;
g?h : i;  // a labelled statement

Picking either interpretation would require a lot of parse-ahead or context-sensitivity in the lexer.

Read full topic


Viewing all articles
Browse latest Browse all 12

Trending Articles