Common Lisp the Language, 2nd Edition

Next: Debugging Tools Up: Miscellaneous Features Previous: Similarity of Constants

# 25.2. Documentation

A simple facility is provided for attaching strings to symbols for the purpose of on-line documentation. Rather than using the property list of the symbol, a separate function `documentation` is provided so that implementations can optimize the storage of documentation strings.

[Function]
`documentation symbol doc-type`

This function returns the documentation string of type doc-type for the symbol, or `nil` if none exists. Both arguments must be symbols. Some kinds of documentation are provided automatically by certain Common Lisp constructs if the user writes an optional documentation string within them:

    Construct               Documentation Type
    ============================================
    defvar                  variable
    defparameter            variable
    defconstant             variable
    defun                   function
    defmacro                function
    defstruct               structure
    deftype                 type
    defsetf                 setf
    ============================================

In addition, names of special forms may also have `function` documentation. (Macros and special forms are not really functions, of course, but it is convenient to group them with functions for documentation purposes.)

`setf` may be used with `documentation` to update documentation information.

X3J13 voted in June 1988 (CLOS) to make `documentation` a CLOS generic function (see chapter 28).

X3J13 voted in March 1989 (FUNCTION-NAME) to extend `documentation` to accept any function-name (a symbol or a list whose car is `setf` - see section 7.1). Thus one may write `(documentation '(setf cadr) 'function)` to determine whether there is any documentation for a `setf` expansion function for `cadr`.

Next: Debugging Tools Up: Miscellaneous Features Previous: Similarity of Constants