6

I have heard that the active symbol table is accessible within the Common Lisp runtime. Have I misunderstood?

Eli Schneider
  • 4,903
  • 3
  • 28
  • 50

2 Answers2

8

'Symbol tables' are called 'packages' in Common Lisp. See for example: Introduction to Packages, CL HyperSpec.

Several operations over packages are available in Common Lisp: The Packages Dictionary.

Symbols can be members of packages (being 'interned').

The variable *package* holds a package as a value, which is used by several operations that use a package as a default. An example is the 'reader', which by default does a look up in the package of *package*.

Rainer Joswig
  • 136,269
  • 10
  • 221
  • 346
  • ohhh so that's where perl packages come from, and why all typeglobs which are entries are always bound to a package O.o – Dmytro Nov 11 '16 at 07:16
5

You can use do-all-symbols.

See here for a similar question. The accepted answer has some details on packages also, which is handy.

Something like this in code. Define useful-symbol-p as you see fit:

(let ((lst ()))
   (do-all-symbols (s lst)
     (when (useful-symbol-p s) (push s lst)))
   lst)
Community
  • 1
  • 1
clstrfsck
  • 14,715
  • 4
  • 44
  • 59