Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!brl-adm!seismo!mcvax!enea!zyx!bd From: bd@zyx.UUCP Newsgroups: comp.lang.lisp Subject: IN-PACKAGE anomaly Message-ID: <372@zyx.UUCP> Date: Thu, 26-Mar-87 19:46:44 EST Article-I.D.: zyx.372 Posted: Thu Mar 26 19:46:44 1987 Date-Received: Mon, 30-Mar-87 03:22:52 EST Reply-To: bd@zyx.UUCP (Bjorn Danielsson) Organization: ZYX Sweden AB, Stockholm Lines: 33 There is a strange anomaly in the IN-PACKAGE function of Common LISP that I would like to call to the attention of this net. Suppose you have two files, one which contains (IN-PACKAGE 'FOO :USE '(BAR)) and the other (IN-PACKAGE 'FOO :USE '(BAZ)) and they are both to be loaded as parts of the same module. The order in which the files are loaded do not affect the final status of the FOO package. So far there is no problem. Now we come to the anomaly: Suppose the second file contains (IN-PACKAGE 'FOO) instead. Suddenly the order in which the files are loaded *does* affect the final status of the FOO package! If the second file is loaded first, then the FOO package will be created by IN-PACKAGE, and it will do an implicit :USE '(LISP). When both files have been loaded, FOO will use *both* the LISP and BAR packages. If the files are loaded in the other order, FOO will use *only* the BAR package! Steele (ISBN 0-932376-41-X) says that if the package already exists when we encounter IN-PACKAGE, the existing package is augmented to reflect any new packages in the :USE list. In this case however, there are no *new* packages in the list, because the list is not there at all. If instead IN-PACKAGE always would default its :USE argument to '("LISP"), the anomaly would go away. One could argue that it is bad programming style to have different use-lists in different files in the same package, but situations like this happen sometimes during the evolution of a program. Any comments are appreciated. -- Bjorn Danielsson, ZYX, +46 8 653205, ...mcvax!enea!zyx!bd