The less-familiar parts of Lisp for beginners — make-symbol

Next, we come to the make-symbol function.  The interested reader might want to review the earlier articles about packages and symbols, and about gensym.  So, make-symbol builds a new symbol object, but does not intern it.  Depending on the needs of the programmer, the symbol can be interned, or it can be used uninterned.  Even uninterned symbols are useful, they can be used as local variables in macro expansions, as those that are returned by gensym, and they will never be eq to any other symbol, even another interned or uninterned symbol with the same name:

CL-USER> (let ((sym-1 (make-symbol "ABC"))
               (sym-2 (make-symbol "ABC"))
               (sym-3 (intern "ABC")))
           (format t "(eq sym-1 sym-2): ~A~%" (eq sym-1 sym-2))
           (format t "(eq sym-1 sym-3): ~A~%" (eq sym-1 sym-3))
           (format t "(eq sym-2 sym-3): ~A~%" (eq sym-2 sym-3)))
(eq sym-1 sym-2): NIL
(eq sym-1 sym-3): NIL
(eq sym-2 sym-3): NIL

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


反垃圾邮件 / Anti-spam question * Time limit is exhausted. Please reload CAPTCHA.