The 'gensym' function generates and returns a symbol. The default symbol form is as a character 'G' followed by a number, 'Gn'. The default numbering starts at '1'. You can change what the generated symbol looks like. By calling 'gensym' with a string 'tag', the default string is set to the string parameter. If 'tag' is an integer number, the current number is set to the integer parameter.
(gensym) ; first time => G1 (gensym 100) ; returns G100 (gensym "MYGENSYM") ; returns MYGENSYM101 (gensym 0) ; returns MYGENSYM0 (gensym) ; returns MYGENSYM1 (gensym "G") ; \ (gensym 0) ; / put it back to 'normal' (gensym) ; just like first time => G1
Note: It takes 2 calls to 'gensym' to set both portions of the 'gensym' symbol.
Note: Although it is possible to call 'gensym' with numbers in the string like "AB1", this does generate an odd sequence. What will happen is you will get a sequence of symbols like:
... AB18 AB19 AB110 AB111 ...
See the
gensym
function in the