3 Common Features

3.7 Displaying packages

Symbols can be referred to either with their package information attached or not. In Common LispWorks, symbols are displayed with the package name attached by default.

For example, suppose you have created a packageFOO which includes a function namedbar and a function namedbaz. Suppose further that you created a new packageFOO2, which used theFOO package. This can be done as shown below:

(defpackage foo (:use "COMMON-LISP"))
(defpackage foo2 (:use "FOO" "COMMON-LISP"))

Note that in defining both packages, theCOMMON-LISP package has also been used. It is good practice to use this package, to ensure that commonly-used functions are available.

When creating packages which use other packages, exported symbols can be called without having to refer to the package name.

To clarify this, let us go back to our example.

Figure 3.1 Two example packages

We have two packages:FOO andFOO2.FOO contains 2 functions,bar andbaz. Suppose that the functionbar has been declared as exported, whereas the functionbaz is not.

When you are in the packageFOO2, you can refer tobar without using the package name (becauseFOO2 usesFOO andbar is exported), but you must still refer to theFOO package name forbaz (becausebaz is not exported). Note also that when you are in any package other thanFOO orFOO2, you can refer tofoo:bar, but you must still refer tofoo::baz.

Package names are usually displayed alongside symbols in a list. Having a package entry on every line can be confusing, especially if the majority of items listed are from the same package. Choose View > Show Package Names to toggle the display of the package name in the current window.

3.7.1 - Specifying a package

Common LispWorks User Guide, Liquid Common Lisp Version 5.0 - 18 OCT 1996

Generated with Harlequin WebMaker