| They could be used as symbols which can be GCed. Though a typical use is in macros, where macros introduce new symbols and these should never clash with any existing symbol and to which there should be no access via the name. Example: A macro which writes the form, the value and which returns the value. GENSYM generates a named/counted uninterned symbol. > (defmacro debugit (form &aux (value-symbol (gensym "value")))
`(let ((,value-symbol ,form))
(format t "~%The value of ~a is ~a~%" ',form ,value-symbol)
,value-symbol))
DEBUGIT
If we look at the expanded code of an example, we can see uninterned symbols: > (pprint (macroexpand-1 '(debugit (sin pi))))
(LET ((#:|value1093| (SIN PI)))
(FORMAT T "~%The value of ~a is ~a~%" '(SIN PI) #:|value1093|)
#:|value1093|)
We can also let the printer show us the identities of these symbols, labelling objects which are used multiple times in an s-expression: > (setf *print-circle* t)
T
> (pprint (macroexpand-1 '(debugit (sin pi))))
(LET ((#2=#:|value1095| #1=(SIN PI)))
(FORMAT T "~%The value of ~a is ~a~%" '#1# #2#)
#2#)
Thus we can see above that it's just one uninterned symbol used in three places.Example run: > (debugit (sin pi))
The value of (SIN PI) is 1.2246063538223773D-16
1.2246063538223773D-16
|
Interesting that gensym returns uninterned symbols, thanks.