Previous: Property Lists, Up: Symbols

7.2 Creating Symbols

These functions create unique symbols, typically for use as temporary variables.

— Function: cl-gensym &optional x

This function creates a new, uninterned symbol (using make-symbol) with a unique name. (The name of an uninterned symbol is relevant only if the symbol is printed.) By default, the name is generated from an increasing sequence of numbers, ‘G1000’, ‘G1001’, ‘G1002’, etc. If the optional argument x is a string, that string is used as a prefix instead of ‘G’. Uninterned symbols are used in macro expansions for temporary variables, to ensure that their names will not conflict with “real” variables in the user's code.

(Internally, the variable cl--gensym-counter holds the counter used to generate names. It is initialized with zero and incremented after each use.)

— Function: cl-gentemp &optional x

This function is like cl-gensym, except that it produces a new interned symbol. If the symbol that is generated already exists, the function keeps incrementing the counter and trying again until a new symbol is generated.

This package automatically creates all keywords that are called for by &key argument specifiers, and discourages the use of keywords as data unrelated to keyword arguments, so the related function defkeyword (to create self-quoting keyword symbols) is not provided.