Go to the first, previous, next, last section, table of contents.


Obarrays

An obarray is the structure used to ensure that no two symbols have the same name and to provide quick access to a symbol given its name. An obarray is basically a vector (with a slight wrinkle), each element of the vector is a chain of symbols which share the same hash-value (a bucket). These symbols are chained together through links which are invisible to Lisp programs: if you examine an obarray you will see that each bucket looks as though it has at most one symbol stored in it.

The normal way to reference a symbol is simply to type its name in the program, when the Lisp reader encounters a name of a symbol it looks in the default obarray for a symbol of that name. If the named symbol doesn't exist it is created and hashed into the obarray -- this process is known as interning the symbol, for more details see section Interning.

Variable: obarray
This variable contains the obarray that the read function uses when interning symbols. If you change this I hope you know what you're doing.

Function: make-obarray size
This function creates a new obarray with size hash buckets (this should be a prime number for best results).

This is the only correct way of making an obarray.

Function: find-symbol symbol-name &optional obarray
This function scans the specified obarray (obarray or the value of the variable obarray if obarray is undefined) for a symbol whose name is the string symbol-name. The value returned is the symbol if it can be found or nil otherwise.

(find-symbol "setq")
    => setq

Function: apropos regexp &optional predicate obarray
Returns a list of symbols from the obarray obarray (or the default) whose print name matches the regular expression regexp. If predicate is defined and not nil, each symbol which matches regexp is applied to the function predicate, if the value is t it is considered a match.

The predicate argument is useful for restricting matches to a certain type of symbol, for example only commands.

(apropos "^yank" 'commandp)
    => (yank-rectangle yank yank-to-mouse)


Go to the first, previous, next, last section, table of contents.