GNU Info

Info Node: (librep.info)Interning

(librep.info)Interning


Next: Property Lists Prev: Creating Symbols Up: Symbols
Enter node , (file) or (file)node

Interning
---------

   "Interning" a symbol means to store it in an obarray so that it can
be found in the future: all variables and named-functions are found
through interned symbols.

   When a symbol is interned a hash function is applied to its print
name to determine which bucket in the obarray it should be stored in.
Then it is simply pushed onto the front of that bucket's chain of
symbols.

   Normally all interning is done automatically by the Lisp reader. When
it encounters the name of a symbol which it can't find in the default
obarray (the value of the variable `obarray') it creates a new symbol
of that name and interns it. This means that no two symbols can have
the same print name, and that the read syntax of a particular symbol
always produces the same object (unless the value of `obarray' is
altered).

     (eq 'some-symbol 'some-symbol)
         => t

 - Function: intern symbol-name #!optional obarray
     This function uses `find-symbol' to search the OBARRAY (or the
     standard obarray) for a symbol called SYMBOL-NAME. If a symbol of
     that name is found it is returned, otherwise a new symbol of that
     name is created, interned into the obarray, and returned.

          (intern "setq")
              => setq
          
          (intern "my-symbol" my-obarray)
              => my-symbol

 - Function: intern-symbol symbol #!optional obarray
     Interns the symbol SYMBOL into the obarray OBARRAY (or the
     standard one) then returns the symbol. If SYMBOL is currently
     interned in an obarray an error is signalled.

          (intern-symbol (make-symbol "foo"))
              => foo
          
          (intern-symbol 'foo)
              error--> Error: Symbol is already interned, foo

 - Function: unintern symbol #!optional obarray
     This function removes the symbol SYMBOL from the obarray OBARRAY
     then returns the symbol.

     Beware! this function should be used with _extreme_ caution--once
     you unintern a symbol there may be no way to recover it.

          (unintern 'setq)                ;This is extremely stupid
              => setq


automatically generated by info2www version 1.2.2.9