[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Package problem, revisted
Date: Tue, 18 August 1992 21:28:50 -0800
From: Philip L. Stubblefield <phil@rpal.rockwell.com>
(defpackage foo ;bad style!
(:use common-lisp)
(:import-from clos class-precedence-list)
(:export bar baz))
This form will create oodles of extraneous symbols in the current package when
read. In fact, if this form is read into the FOO package, perhaps because of
the file attribute line, then trouble is sure to follow. The reader will intern
a symbol having the name "CLASS-PRECEDENCE-LIST" into the current package when
this form is read. Then when the :IMPORT-FROM clause is executed, *boom*, a
name conflict occurs.
There's nothing wrong with that form, in my opinion. One of the features
of DEFPACKAGE is that it coerces symbol and package names to strings, so
that you don't have to clutter up your form with quotes. However, package
creation should generally be done in a neutral package (e.g. the USER
package). It makes no sense to do the creation of a package with the
package already set to that package. The ANSI DEFPACKAGE is explicitly
permitted to have undefined behavior if the package already exists and is
inconsistent with the description in the DEFPACKAGE; precreating the
package is likely to have this result.