编译器概念问题 [英] Compiler Concepts Problem
本文介绍了编译器概念问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么编译器不允许创建以整数或仅以整数开头的变量名.例如:为什么不可能,
int 9abc = 46;
或
int 9 = 10;
请帮助
why does compiler does not allows to create a variable name starting with integer or integer only. For example: why is it not possible,
int 9abc=46;
or
int 9=10;
please help
推荐答案
,因为要区分用作名称的数字和仅是数字的数字更加困难.它在很大程度上是历史性的,但规则是规则.还有上面您建议的表达式:
Because it is more difficult to distinguish between a number that is used as a name and a number that is just a number. It''s largely historical, but the rules are the rules. And an expression such as you suggest above:
int 9=10;
只是愚蠢.
is just plain stupid.
简单的答案是因为它违反了C语言规范"
原因很简单:它消除了混乱.如果您确实允许变量以数字开头怎么办?
The simple answer is "Because it is against the C language specification"
The reason why is pretty simple: it removes confusion. What if you did allow variables to start with numbers?
number = 1E6;
这是指1000000吗?还是尚未定义的名为"1E6"的变量?
Does this refer to 1000000? Or a variable called "1E6" that hasn''t been defined yet?
这篇关于编译器概念问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文