试试一个变量名最长可以有多长?
In computer languages, identifiers are tokens (also called symbols) which name language entities. Some of the kinds of entities an identifier might denote include variables, types, labels, subroutines, and packages.
Which character sequences constitute identifiers depends on the lexical grammar of the language. A common rule is alphanumericsequences, with underscore also allowed, and with the condition that it not begin with a digit (to simplify lexing by avoiding confusing with integer literals) – so foo, foo1, foo_bar, _foo
are allowed, but 1foo
is not – this is the definition used in earlier versions of C, and many other languages.
Reserved keywords
The following words are reserved, and may not be used as identifiers:
|
|
|
|
Implementations may reserve other keywords, such as asm, although implementations typically provide non-standard keywords that begin with one or two underscores.
Case sensitivity
C identifiers are case sensitive (e.g., foo, FOO, and Foo are the names of different objects). Some linkers may map external identifiers to a single case, although this is uncommon in most modern linkers.
Comments