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

My wild guess is that question marks are not allowed in identifiers for the simple reason that it is uncommon among programming languages to allow punctuation marks in identifiers.

There is probably no chance for adding support of question marks in identifiers, because it would be difficult (impossible?) to maintain BC while keeping a provably unambiguous grammar or a reasonably efficient parser: a? - b : c should continue to be parsed as a ? -b : c.

But question marks are not required to “add context”: you can use another convention, for example prefixing the name with is_.

Read full topic


Viewing all articles
Browse latest Browse all 12

Trending Articles