Next: , Previous: , Up: Symbols   [Contents][Index]


5.6.4 Creating Symbols

It is possible to allocate symbols dynamically, this is normally only necessary when the symbol is to be interned in a non-default obarray or the symbol is a temporary object which should not be interned (for example: labels in a compiler).

Function: make-symbol print-name

This function creates and returns a new, uninterned, symbol whose print name is the string print-name. Its value cell is void (undefined) and it will have an empty property list.

If you’re unsure, use intern instead. (see Interning.)

(make-symbol "foo")
    ⇒ foo

(eq 'foo (make-symbol "foo"))
    ⇒ ()

(eq 'foo (intern "foo"))
    ⇒ t
Function: gensym

This function returns a new, uninterned, symbol that has a unique print name.

(gensym)
    ⇒ G0001

(gensym)
    ⇒ G0002