3.4 Customizing the environment

3.4.3 Displaying packages

Common Lisp uses a system of packages for collecting related symbols together in a group, or package. If you are not interested in Common Lisp packages, you need not continue with this or the following section.

When referring to symbols, you can choose either to precede each symbol with the package name, or not. The way in which package names are shown, by convention, gives information about the symbol concerned.

For example, suppose you have created a package FOO which includes a function named bar and a function named baz. Suppose further that you created a new package FOO2, which used the FOO package. This can be done as shown below:

(defpackage foo (:use cl lw))
(defpackage foo2 (:use foo cl lw))

Note: When defining both packages, the cl (Common Lisp) and lw (LispWorks) packages were used. It is good practice to use these packages in package definitions in order to ensure that commonly used functions are available in the new package.

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

To clarify this, let us return to our example.

Figure 3.1 Symbols and packages.

We have two packages: FOO and FOO2. FOO contains 2 functions, bar and baz. Suppose that the function bar is declared as exported, whereas the function baz is not.

When you are in the package FOO2, you can refer to bar without using the package name (because FOO2 uses FOO and bar is exported), but you must still refer to the package name for baz (because baz is not exported).

Note also that when you are in any package other than FOO or FOO2, you can say foo:bar, but you must still say foo::baz.

Package names are often displayed alongside symbols in a list pane. Having a package entry on every line can be confusing, especially if the majority of list items are available from the same package. You can control whether or not packages are displayed in the current window using the Packages item of the Customize submenu.

Once again, selecting the Packages option toggles its setting between on and off.


FreeLisp User's Guide - 5 FEB 1996

Generated with Harlequin WebMaker