Common Lisp HyperSpec: unbound symbol handling in conforming implementations

136 Views Asked by At

This is a pretty technical question about conforming implementations of the ANSI Lisp spec:

In Section 2.3.4, it says that a token read as a symbol that's not available in the current package is interred as a new symbol in the current package.

In Section 3.1.2.1, it says that if a symbol isn't bound, an error is given.

What happens to unbound symbols between iterations of the REPL? Will a conforming implementation remove unbound symbols from the current package, or will it keep interning symbols until the REPL occupies all available memory?

1

There are 1 best solutions below

7
Barmar On BEST ANSWER

Once you intern a symbol, it stays interned until you explicitly unintern it. And if you type the name of an interned symbol, that same symbol is returned.

The reader doesn't care whether a symbol is bound or not. That only becomes relevant if you try to evaluate the symbol. But symbols can be used without being evaluated, for instance as part of quoted data, or when the program calls READ itself.