7 Additional Extensions to Common Lisp

7.3 Packages

A package is a Common Lisp object that specifies a mapping between print name strings and symbols. Packages allow two different modules to safely use the same name for different internal purposes without name conflicts.

Each package has a unique name; it can also have nicknames. Operations that compare package names are case sensitive. When package names are read by the Lisp reader, lowercase characters are converted to uppercase unless they are preceded by the escape character \ or are enclosed by the | multiple escape characters.

The symbols whose string-to-symbol mappings are specified by a given package are said to be present symbols in that package. Each such symbol is either an external symbol or an internal symbol of that package, but not both. An external symbol of a package is part of that package's public interface and is accessible to other packages. An internal symbol is intended for the private use by the functions and definitions of the programs contained in that package.

Names within a package are unique. Two different symbols with the same name cannot coexist in the same package. Note, however, that the same symbol can be an external symbol in some packages and an internal symbol in others.

A symbol is owned by only one package. The package that owns the symbol is called the symbol's home package. The package cell of the symbol specifies the symbol's home package. If a symbol is owned by any package, it is said to be an interned symbol. A symbol not owned by any package is said to be an uninterned symbol. The package cell of an uninterned symbol isnil.

A symbol is an accessible symbol in a package if it is present in the package or if it is an inherited symbol from some other package (by means of the Common Lispuse-package construct). Only the external symbols of a package can be inherited by other packages.

Only one package is the current package at any given time. The Lisp reader interprets names as symbols according to the mappings specified by the current package. The current package is the package that is specified by the Common Lisp variable*package*.

A file is in a package if it is intended to be read while the value of*package* is that package. Normally, this intention is specified by placing a Common Lispin-package statement at the beginning of the file and by assuring that no other package statements occur within the file.

You can reference an external, internal, or inherited symbol of the current package by its name. To reference an external symbol of some other package that is not otherwise available in the current package, you must qualify the package: precede the symbol name with the package name and one colon. If you qualify a symbol name by preceding it with the package name and two colons, you can reference any symbol accessible in another package. Since internal symbols are normally intended for the private use of a package, accessing the internal symbols of a package that is not current can violate the commonly accepted conventions that promote uniformity between compiled and interpreted loadings. A reference to a symbol using double-colon notation can inadvertently create an interned symbol where none existed before; a reference using the single-colon notation signals an error if the specified symbol is not already present and external.

7.3.1 - Built-in packages
7.3.2 - Changes to make-package
7.3.3 - Extended package constructs
7.3.4 - Using packages in interpreted and compiled code
7.3.5 - Reference pages

The Advanced User's Guide - 9 SEP 1996

Generated with Harlequin WebMaker