You can list all the existing packages with:
(list-all-packages)
For a given package, you can iterate over all its symbols or its external symbols:
(do-symbols (sym package)
...)
(do-external-symbols (sym package)
...)
You can also directly list all symbols in all packages:
(do-all-symbols (sym)
...)
When using Slime, inspecting a symbol with slime-inspect
gives a summary of all things named after that symbol; for example, if I inspect 'number
, the following is shown:
#<SYMBOL {5024C0CF}>
--------------------
Its name is: "NUMBER"
It is unbound.
It has no function value.
It is external to the package: COMMON-LISP [unintern]
Property list: NIL
It names the class NUMBER [remove]
It names a primitive type-specifier.
The NUMBER
and COMMON-LISP
texts above are also buttons, which you can click to visit the associated value. If you are only using SBCL, the same can be achieved by calling (find-class symbol nil)
(the NIL indicates that no error should be reported if the symbol does not name a class), (symbol-plist symbol)
, etc.
There are some things which cannot be introspected according to the standard, like structs or the list of all user-defined types introduced with deftype
(maybe other things). Depending on what you want to do, you may need to have a look at an implementation-specific way of doing this.
Thanks to David Hodge for pointing out the following:
A package called repl-utilities from Rob Warnock has a neat function called summary which shows each function, global variable with associated docstrings