The lexical flexibility for symbols in RScheme could be a curse if used indiscriminantly. Therefore, through experience and historical precedent, some conventions for variable names have been developed. (Note that in programs, identifiers are represented by what would be symbols in data)
Many permissible special characters are simply not used. The period and percent sign are particularly discouraged[1]. This convention will be particularly important in RScheme because in an alternative Java-like syntax (under development), many valid scheme symbols are not identifiers (due to the use of special characters for operators).
Although RScheme is case sensitive, names are usually in all lower case with dashes to separate words.
Some specific naming conventions are used to distinguish different kinds of variables.
Table 2-2. Examples of identifiers following conventions
Identifier | Description |
---|---|
*foo* | normal, mutable module variable |
<foo> | class variable |
foo | function or special form |
foo! | function or special form with side-effects (pronounced "bang", as in set! which is read "set-bang") |
foo? | predicate or boolean-returning function |
$foo | constant |
With respect to the notational convention for side-effects, the use of an exclamation mark (!) suffix, not all functions with side-effects are so marked. This convention applies primarily to low-level functions or functions whose primary purpose is to have side effects, such as vector-set! and delq!.
[1] | Although the period is currently being used as a level separator in a hierarchical namespace of modules. |