User Tools

Function GENTEMP


  • gentemp &optional prefix packagenew-symbol

Arguments and Values


gentemp creates and returns a fresh symbol, interned in the indicated package.

The symbol is guaranteed to be one that was not previously accessible in package. It is neither bound nor fbound, and has a null property list.

The name of the new-symbol is the concatenation of the prefix and a suffix, which is taken from an internal counter used only by gentemp. (If a symbol by that name is already accessible in package, the counter is incremented as many times as is necessary to produce a name that is not already the name of a symbol accessible in package.)




(gentemp "FOO")


(find-symbol "FOO1300")


(gentemp "FOO")


(find-symbol "FOO1300")


(intern "FOO1301")


(gentemp "FOO")




Side Effects

Its internal counter is incremented one or more times.

Interns the new-symbol in package.

Affected By

The current state of its internal counter, and the current state of the package.

Exceptional Situations

Should signal an error of type type-error if prefix is not a string. Should signal an error of type type-error if package is not a package designator.

See Also


The function gentemp is deprecated.

If package is the package keyword, the result is an external symbol of package. Otherwise, the result is an internal symbol of package.

The gentemp internal counter is independent of *gensym-counter*, the counter used by gensym. There is no provision for accessing the gentemp internal counter.

Just because gentemp creates a symbol which did not previously exist does not mean that such a symbol might not be seen in the future (e.g. in a data file - perhaps even created by the same program in another session). As such, this symbol is not truly unique in the same sense as a gensym would be. In particular, programs which do automatic code generation should be careful not to attach global attributes to such generated symbols (e.g. special declarations) and then write them into a file because such global attributes might, in a different session, end up applying to other symbols that were automatically generated on another day for some other purpose.