Next: , Up: Lexical conventions   [Index]


2.1 Identifiers

An identifier is any sequence of letters, digits, and “extended identifier characters” provided that it does not have a prefix which is a valid number. However, the . token (a single period) used in the list syntax is not an identifier.

All implementations of Scheme must support the following extended identifier characters:

! $ % & * + - . / : < = > ?  ^ _ ~

Alternatively, an identifier can be represented by a sequence of zero or more characters enclosed within vertical lines (‘|’), analogous to string literals. Any character, including whitespace characters, but excluding the backslash and vertical line characters, can appear verbatim in such an identifier. In addition, characters can be specified using either an ⟨inline hex escape⟩ or the same escapes available in strings.

For example, the identifier |H\x65;llo| is the same identifier as Hello, and in an implementation that supports the appropriate Unicode character the identifier |\x3BB;| is the same as the identifier λ. What is more, |\t\t| and |\x9;\x9;| are the same. Note that || is a valid identifier that is different from any other identifier.

Here are some examples of identifiers:

...                      +
+soup+                   <=?
->string                 a34kTMNs
lambda                   list->vector
q                        V17a
|two words|              |two\x20;words|
the-word-recursion-has-many-meanings

See Formal syntax for the formal syntax of identifiers.

Identifiers have two uses within Scheme programs:

In contrast with earlier revisions of the report [R5RS], the syntax distinguishes between upper and lower case in identifiers and in characters specified using their names. However, it does not distinguish between upper and lower case in numbers, nor in ⟨inline hex escapes⟩ used in the syntax of identifiers, characters, or strings. None of the identifiers defined in this report contain upper-case characters, even when they appear to do so as a result of the English-language convention of capitalizing the first word of a sentence.

The following directives give explicit control over case folding.

#!fold-case
#!no-fold-case

These directives can appear anywhere comments are permitted (see Whitespace and comments) but must be followed by a delimiter. They are treated as comments, except that they affect the reading of subsequent data from the same port. The #!fold-case directive causes subsequent identifiers and character names to be case-folded as if by string-foldcase (see Strings). It has no effect on character literals. The #!no-fold-case directive causes a return to the default, non-folding behavior.


Next: Whitespace and comments, Up: Lexical conventions   [Index]