From: ···········@gmail.com
Subject: package question
Date: 
Message-ID: <1166296602.626839.266000@16g2000cwy.googlegroups.com>
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

From: Pascal Bourguignon
Subject: Re: package question
Date: 
Message-ID: <8764cbh97k.fsf@thalassa.informatimago.com>
···········@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!"
From: ···········@gmail.com
Subject: Re: package question
Date: 
Message-ID: <1166384224.300447.324290@t46g2000cwa.googlegroups.com>
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
From: Pascal Bourguignon
Subject: Re: package question
Date: 
Message-ID: <87psaib3bu.fsf@thalassa.informatimago.com>
···········@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.
From: ···········@gmail.com
Subject: Re: package question
Date: 
Message-ID: <1166394014.224170.309690@80g2000cwy.googlegroups.com>
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