Common Lisp the Language, 2nd Edition

Next: Package Names Up: Packages Previous: Packages

# 11.1. Consistency Rules

Package-related bugs can be very subtle and confusing: things are not what they appear to be. The Common Lisp package system is designed with a number of safety features to prevent most of the common bugs that would otherwise occur in normal use. This may seem over-protective, but experience with earlier package systems has shown that such safety features are needed.

In dealing with the package system, it is useful to keep in mind the following consistency rules, which remain in force as long as the value of `*package*` is not changed by the user:

- Read-read consistency: Reading the same print name always results in the same (`eq`) symbol.

- Print-read consistency: An interned symbol always prints as a sequence of characters that, when read back in, yields the same (`eq`) symbol.

- Print-print consistency: If two interned symbols are not `eq`, then their printed representations will be different sequences of characters.

These consistency rules remain true in spite of any amount of implicit interning caused by typing in Lisp forms, loading files, etc. This has the important implication that, as long as the current package is not changed, results are reproducible regardless of the order of loading files or the exact history of what symbols were typed in when. The rules can only be violated by explicit action: changing the value of `*package*`, forcing some action by continuing from an error, or calling one of the ``dangerous'' functions `unintern`, `unexport`, `shadow`, `shadowing-import`, or `unuse-package`.

Next: Package Names Up: Packages Previous: Packages