Hi
I have a small problem with defpackage which I'm sure has an easy
solution but...
Here's the problem:
(defpackage :foobar
(:use #:common-lisp)
(:export #:type)
(:shadow #:type))
That's the base package. To test it, I create a user package
(defpackage :foobar-user
(:use #:foobar
#:common-lisp)
(:shadowing-import-from #:common-lisp #:type))
(eval-when (:compile-toplevel)
(loop :as symbol :being :the symbol :in (find-package '#:foobar)
:do (import symbol)))
In this case, I get a symbol conflict between because FOOBAR:TYPE and
FOOBAR-USER:TYPE
I've tried other combinations but none work. Not shadowing causes a
conflict between COMMON-LISP:TYPE and FOOBAR:TYPE
What should I do?
Cheers
Vijay Lakshminarayanan
···········@gmail.com writes:
> Hi
>
> I have a small problem with defpackage which I'm sure has an easy
> solution but...
>
> Here's the problem:
>
> (defpackage :foobar
> (:use #:common-lisp)
> (:export #:type)
> (:shadow #:type))
>
> That's the base package. To test it, I create a user package
>
> (defpackage :foobar-user
> (:use #:foobar
> #:common-lisp)
> (:shadowing-import-from #:common-lisp #:type))
>
> (eval-when (:compile-toplevel)
> (loop :as symbol :being :the symbol :in (find-package '#:foobar)
> :do (import symbol)))
>
> In this case, I get a symbol conflict between because FOOBAR:TYPE and
> FOOBAR-USER:TYPE
>
> I've tried other combinations but none work. Not shadowing causes a
> conflict between COMMON-LISP:TYPE and FOOBAR:TYPE
>
> What should I do?
You should decide what symbol you want to have in foobar-user?
COMMON-LISP:TYPE or FOOBAR:TYPE?
--
__Pascal Bourguignon__ http://www.informatimago.com/
"Specifications are for the weak and timid!"
Pascal Bourguignon wrote:
> ···········@gmail.com writes:
[snip]
> You should decide what symbol you want to have in foobar-user?
> COMMON-LISP:TYPE or FOOBAR:TYPE?
I want FOOBAR:TYPE in FOOBAR-USER
Cheers
Vijay Lakshminarayanan
···········@gmail.com writes:
> Pascal Bourguignon wrote:
>> ···········@gmail.com writes:
>
> [snip]
>
>> You should decide what symbol you want to have in foobar-user?
>> COMMON-LISP:TYPE or FOOBAR:TYPE?
>
> I want FOOBAR:TYPE in FOOBAR-USER
(defpackage "FOOBAR"
(:use "COMMON-LISP")
(:shadow "TYPE")
(:export "TYPE"))
(defpackage "FOOBAR-USER"
(:use "COMMON-LISP" "FOOBAR")
(:shadowing-import-from "FOOBAR" "TYPE"))
(in-package "FOOBAR-USER")
(symbol-package 'type)
--> #<PACKAGE FOOBAR>
--
__Pascal Bourguignon__ http://www.informatimago.com/
PLEASE NOTE: Some quantum physics theories suggest that when the
consumer is not directly observing this product, it may cease to
exist or will exist only in a vague and undetermined state.
Pascal Bourguignon wrote:
> ···········@gmail.com writes:
>
> > Pascal Bourguignon wrote:
> >> ···········@gmail.com writes:
> >
> > [snip]
> >
> >> You should decide what symbol you want to have in foobar-user?
> >> COMMON-LISP:TYPE or FOOBAR:TYPE?
> >
> > I want FOOBAR:TYPE in FOOBAR-USER
>
> (defpackage "FOOBAR"
> (:use "COMMON-LISP")
> (:shadow "TYPE")
> (:export "TYPE"))
>
> (defpackage "FOOBAR-USER"
> (:use "COMMON-LISP" "FOOBAR")
> (:shadowing-import-from "FOOBAR" "TYPE"))
>
> (in-package "FOOBAR-USER")
> (symbol-package 'type)
> --> #<PACKAGE FOOBAR>
*slaps-hand-on-head*
>From HyperSpec:
shadowing-import is like import, but it does not signal an error even
if the importation of a symbol would shadow some symbol already
accessible in package.
I completely misread that.
Thanks Pascal.
Cheers
Vijay Lakshminarayanan