[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: problems with packages



Dan Stanger <dxs@evolving.com> reports the following problem with SHADOW:

> (defpackage "SETS-PACK" (:use "COMMON-LISP" "CLOS")
>   (:shadow "SETS" "INTERSECTION")
>   (:export "SETS" "INTERSECTION"))
> (use-package "SETS-PACK")
> ** - Continuable Error
> 1 name conflicts while executing USE-PACKAGE of (#<PACKAGE SETS-PACK>)
> 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
                    haible@ma2s2.mathematik.uni-karlsruhe.de