2.5 Identifiers

An identifier is used to refer to a variable (see Variables). An identifier consists of letters, digits, and underscores _, and must contain at least one letter or underscore. 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 identifier.

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.

Previous Up Top Next
Index

GAP 3.4.4
April 1997