Why can't the variable names in the computer language start with numbers?

Source: Internet
Author: User

Variable name definition: The variable name consists of a letter, a number, an underscore, where the first character cannot be a number.

Explanation One, lexical analysis said (https://www.zhihu.com/question/19581495)

Because each time you enter the "head symbol" to determine whether the symbol is a number or a character, if it is a number, you can jump directly into the digital processing module, if the character is processed by the variable name.  If the variable name is allowed to start with a number, then each time you enter a symbol to make a "whether is a number" judgment, until the symbol appears non-numeric and then turn into a variable name, and prohibit to start with a number only need to judge once, it is clear that "every time to judge" is a great waste. In addition, the variable name with the beginning of the number of the programmer also does not have any help, but lower the performance of the compiler, after all, O (1) and O (n) is not a small gap. Explanation Two, the existing data can not distinguish scientific counts: 1E3 Some values: 100000l,100f program logic error: int 1 = 2; if (1 = = 2) {...}

Why can't the variable names in the computer language start with numbers?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.