Search code examples
lispcommon-lisp

lisp: describing every external thing in a package


I'm sure the answer is obvious, but I'm banging my head against this one. I'm trying to describe every externally defined thing in a LISP package. The following (SBCL) code prints the symbols just fine:

(require "sb-posix")
(do-external-symbols (single-symbol 'sb-posix)
  (prin1 single-symbol) (terpri))

... so I was hoping that something like this would do the job, but it doesn't:

(require "sb-posix")
(do-external-symbols (single-symbol 'sb-posix)
  (describe sb-posix:single-symbol))

The first two lines of the error message I get are:

Unhandled SB-INT:SIMPLE-READER-PACKAGE-ERROR:
  Symbol "SINGLE-SYMBOL" not found in the SB-POSIX package.

What obvious correction am I missing?


Solution

  • Your code binds a variable single-symbol to the value of each external symbol in sb-posix. The symbol naming the variable is in the current package (as specified by cl:*package*), not in the sb-posix package, and should not be referenced with an sb-posix package prefix.