Subject: problems with packages

From: [email-masked] (Dan Stanger)
Date: Tue, 31 Jan 1995 16:58:00 -0700

i have the following 3 files.
more c.lsp
(use-package "CLOS")
(load 's)
(load 'p)
 
 more s.lsp
(defpackage "SETS-PACK" (:use "COMMON-LISP" "CLOS")
  (:shadow "SETS" "INTERSECTION")
  (:export "SETS" "INTERSECTION"))
(in-package "SETS-PACK")
(defclass sets ()
 ((tipe :accessor tipe :initarg :tipe)
  (elements :accessor elements)))
(defgeneric intersection (a b &key test test-not key))
(defmethod intersection ((s1 sets) (s2 sets) &rest more)
  (unless (equal (tipe s1) (tipe s2)) (error "bad type"))
  (apply #'lisp:intersection (elements s1) (elements s2) more))
(defmethod intersection ((s1 sequence) (s2 sequence) &rest more)
  (apply #'lisp:intersection s1 s2 more))
 
and more p.lsp
(use-package "SETS-PACK")
(setf a (make-instance 'sets :tipe 't))  

when i execute clips as follows i get the error
clisp -q -i c.lsp
;; Loading file c.lsp ...
;; Loading file /home/dxs/l/s.lsp ...
;; Loading of file /home/dxs/l/s.lsp is finished.
;; Loading file /home/dxs/l/p.lsp ...
** - Continuable Error
1 name conflicts while executing USE-PACKAGE of (#<PACKAGE SETS-PACK>) into package #<PACKAGE USER>.
If you continue (by typing 'continue'): You may choose for every conflict in favour of which symbol to resolve it.
1. Break>continue
which symbol with name "INTERSECTION" should be accessible in #<PACKAGE USER> ?
Please choose:
          1  --  SETS-PACK
          2  --  USER
 
i thought that shadowing intersection would eliminate this problem.
does anybody have any ideas on this?
thanks,
dan stanger

---

From: haible (Bruno Haible)
Date: Wed, 1 Feb 95 01:35:10 +0100

> into package #<PACKAGE USER>.

The :shadow option to DEFPACKAGE only prohibits name conflicts in package
SETS-PACK.

The conflict appears because package USER also has to choose among
LISP:INTERSECTION and SETS-PACK:INTERSECTION.

Michael Stoll has developed the following trick to handle this.
In your SETS-PACKAGE add a macro (which you export as well):

(eval-when (eval load)
  (defmacro use-sets-package ()
    `(progn (shadowing-import (list (find-symbol "INTERSECTION" "SETS-PACKAGE"))
                              *package*
            )
            (use-package "SETS-PACKAGE")
     )
) )

Then, instead of writing  (use-package "SETS-PACKAGE"), you only write
(sets-package:use-sets-package).

This is, admittedly, a bit clumsy. Has anyone found another solution to this
problem?

                    Bruno Haible
                    [email-masked]