Any reasonably modern version of Lisp (including Emacs Lisp and, of course, Common Lisp) allows documentation to be attached to symbols in the form of documentation strings. This is not quite literate programming, but it does give a handy way of adding searchable documentation to all you write.

It's particularly easy to document functions: just add the string after the argument list (since this will be followed by other forms to evaluate, even a Lisp without documentation strings will accept the defun, and give the same results when evaluating!):

(defun factorial (n)
  "Compute N!
If N is large and your Lisp doesn't have bignums, will overflow"
  (if (< n 2) 1 (* n (factorial (- n 1)))))

In Emacs, you can access a function's documentation string with "C-h f", and a variable's documentation string with "C-h v".

Log in or register to write something here or to contact authors.