Generally you put that kind of limitation in for two reasons:
- It's a pain to parse electronically.
- It's a pain for humans to parse.
Consider the following code snippet:
int d, -d;
d = 3;
-d = 2;
d = -d;
If -d
is a legal identifier, then which value does d
have at the end? -3 or 2? It's ambiguous.
Also consider:
int 2e10f, f;
2e10f = 20;
f = 2e10f;
What value does f
have at the end? This is also ambiguous.
Also, it's a pain to read either way. If someone declares 2ex10
, is that a typo for two million or a variable name?
Making sure that identifiers start with letters means that the only language items they can conflict with are reserved keywords.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…