0% found this document useful (0 votes)
4 views1 page

Understanding Valid Identifiers in Programming

An identifier is used to refer to a variable and usually consists of letters, digits, and underscores. An identifier must contain at least one non-digit and is terminated by the first character not in this class. Examples of valid identifiers include variable names like foo, aLongIdentifier, and identifiers containing numbers or underscores. Case is significant in identifiers and the backslash can be used to include other characters, with a backslash followed by a character being equivalent to just the character.

Uploaded by

ravg10
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Understanding Valid Identifiers in Programming

An identifier is used to refer to a variable and usually consists of letters, digits, and underscores. An identifier must contain at least one non-digit and is terminated by the first character not in this class. Examples of valid identifiers include variable names like foo, aLongIdentifier, and identifiers containing numbers or underscores. Case is significant in identifiers and the backslash can be used to include other characters, with a backslash followed by a character being equivalent to just the character.

Uploaded by

ravg10
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Identifiers

By:Gap

An identifier is used to refer to a variable (see Variables). An identifier usually consists of letters,
digits, and underscores _, and must contain at least one non-digit. An identifier is terminated by the
first character not in this class. Examples of valid identifiers are
a foo aLongIdentifier
hello Hello HELLO
x100 100x _100
some_people_prefer_underscores_to_separate_words
WePreferMixedCaseToSeparateWords

Note that case is significant, so the three identifiers in the second line are distinguished.
The backslash \ can be used to include other characters in identifiers; a backslash followed by a
character is equivalent to the character, except that this escape sequence is considered to be an
ordinary letter. For example
G\(2\,5\)

is an identifier, not a call to a function G.


An identifier that starts with a backslash is never a keyword, so for example \* and \mod are
identifiers.
The length of identifiers is not limited, however only the first 1023 characters are significant. The
escape sequence \newline is ignored, making it possible to split long identifiers over multiple lines.
• IsValidIdentifier( str ) F
returns true if the string str would form a valid identifier consisting of letters, digits and
underscores; otherwise it returns false. It does not check whether strcontains characters escaped by
a backslash \.

Reference : [Link]
Date:17-9-2008

You might also like