Common Lisp the Language, 2nd Edition


next up previous contents index
Next: Translating Strings to Up: Packages Previous: Consistency Rules

11.2. Package Names

Each package has a name (a string) and perhaps some nicknames. These are assigned when the package is created, though they can be changed later. A package's name should be something long and self-explanatory, like editor; there might be a nickname that is shorter and easier to type, such as ed.

There is a single name space for packages. The function find-package translates a package name or nickname into the associated package. The function package-name returns the name of a package. The function package-nicknames returns a list of all nicknames for a package. The function rename-package removes a package's current name and nicknames and replaces them with new ones specified by the user. Package renaming is occasionally useful when, for development purposes, it is desirable to load two versions of a package into the same Lisp. One can load the first version, rename it, and then load the other version, without getting a lot of name conflicts.

When the Lisp reader sees a qualified symbol, it handles the package-name part in the same way as the symbol part with respect to capitalization. Lowercase characters in the package name are converted to corresponding uppercase characters unless preceded by the escape character or surrounded by | characters. The lookup done by the find-package function is case-sensitive, like that done for symbols. Note that |Foo|:|Bar| refers to a symbol whose name is Bar in a package whose name is Foo. By contrast, |Foo:Bar| refers to a seven-character symbol that has a colon in its name (as well as two uppercase letters and four lowercase letters) and is interned in the current package. Following the convention used in this book for symbols, we show ordinary package names using lowercase letters, even though the name string is internally represented with uppercase letters.

Most of the functions that require a package-name argument from the user accept either a symbol or a string. If a symbol is supplied, its print name will be used; the print name will already have undergone case-conversion by the usual rules. If a string is supplied, it must be so capitalized as to match exactly the string that names the package.

change_begin
X3J13 voted in January 1989 (PACKAGE-FUNCTION-CONSISTENCY)   to clarify that one may use either a package object or a package name (symbol or string) in any of the following situations:

Note that the first argument to make-package must still be a package name and not an actual package; it makes no sense to create an already existing package. Similarly, package nicknames must always be expressed as package names and not as package objects. If find-package is given a package object instead of a name, it simply returns that package.
change_end



next up previous contents index
Next: Translating Strings to Up: Packages Previous: Consistency Rules


AI.Repository@cs.cmu.edu