From: Sam Steingold
Subject: CLtS: with-package-iterator & re-exporting
Date: 
Message-ID: <uk85hxuu6.fsf@xchange.com>
Suppose I re-export a symbol:

(defpackage "BAR" (:use))
(defpackage "FOO" (:use "BAR"))
(intern "ZOT" "BAR")
(export 'BAR::ZOT "BAR")

Then define for convenience:

(defmacro wpi (&rest what)
  `(with-package-iterator (generator-fn "FOO" ,@what)
    (loop (multiple-value-bind (more? symbol accessibility pkg)
              (generator-fn)
            (declare (ignore pkg))
            (unless more? (return))
            (print (list symbol accessibility))))))

What should (wpi :external) and (wpi :internal) print?
Since `BAR:ZOT' is present in "FOO" and is exported,
        (wpi :external) should print (BAR:ZOT :EXTERNAL)
Since `BAR:ZOT' is exported by "BAR" and not shadowed in "FOO",
        (wpi :inherited) should print (BAR:ZOT :INHERITED)
Indeed, that's the behavior of ACL6 and CLISP (but not CMUCL, which does
not print anything on (wpi :inherited)).

Now, what should
        (do-symbols (x "FOO")
          (print (multiple-value-list (find-symbol (symbol-name x) "FOO"))))
print?

ACL6:  (bar:zot :inherited)
CLISP: (BAR:ZOT :EXTERNAL)
CMUCL: (BAR:ZOT :EXTERNAL)

This means that (test-package-iterator "FOO"), defined in
http://www.lisp.org/HyperSpec/Body/mac_with-package-iterator.html,
will throw an error:
        Symbol BAR:ZOT not found as :INHERITED in package FOO [(BAR:ZOT :EXTERNAL)]
in CLISP and
        Symbol BAR:ZOT not found as :EXTERNAL in package FOO [(BAR:ZOT :INHERITED)]
in ACL6 (it works fine in CMUCL)

So, what is going on here?
What should (wpi :external :inherited) print?
What about do-symbols?

Thanks.

-- 
Sam Steingold (http://www.podval.org/~sds)
UNIX is a way of thinking.  Windows is a way of not thinking.

From: Sam Steingold
Subject: Re: CLtS: with-package-iterator & re-exporting
Date: 
Message-ID: <ubsqtxrfa.fsf@xchange.com>
> * In message <·············@xchange.com>
> * On the subject of "CLtS: with-package-iterator & re-exporting"
> * Sent on 22 Mar 2001 18:11:29 -0500
> * Honorable Sam Steingold <···@gnu.org> writes:
>
> Suppose I re-export a symbol:
> 
> (defpackage "BAR" (:use))
> (defpackage "FOO" (:use "BAR"))
> (intern "ZOT" "BAR")
> (export 'BAR::ZOT "BAR")

I forgot the most important line:

(export 'BAR:ZOT "FOO")

without it my message does not make sense!

Sorry.

-- 
Sam Steingold (http://www.podval.org/~sds)
Parachute for sale, once used, never opened, small stain.
From: Barry Margolin
Subject: Re: CLtS: with-package-iterator & re-exporting
Date: 
Message-ID: <D2wu6.76$U4.3505@burlma1-snr2>
In article <·············@xchange.com>, Sam Steingold  <···@gnu.org> wrote:
>Suppose I re-export a symbol:
>
>(defpackage "BAR" (:use))
>(defpackage "FOO" (:use "BAR"))
>(intern "ZOT" "BAR")
>(export 'BAR::ZOT "BAR")
>
>Then define for convenience:
>
>(defmacro wpi (&rest what)
>  `(with-package-iterator (generator-fn "FOO" ,@what)
>    (loop (multiple-value-bind (more? symbol accessibility pkg)
>              (generator-fn)
>            (declare (ignore pkg))
>            (unless more? (return))
>            (print (list symbol accessibility))))))
>
>What should (wpi :external) and (wpi :internal) print?
>Since `BAR:ZOT' is present in "FOO" and is exported,
>        (wpi :external) should print (BAR:ZOT :EXTERNAL)

I disagree.  Internal and external are relative to a particular package.
You asked for the symbols that are exported from FOO, and BAR:ZOT is only
exported from BAR, not from FOO.  So it shouldn't show up here.

>Since `BAR:ZOT' is exported by "BAR" and not shadowed in "FOO",
>        (wpi :inherited) should print (BAR:ZOT :INHERITED)
>Indeed, that's the behavior of ACL6 and CLISP (but not CMUCL, which does
>not print anything on (wpi :inherited)).

I suspect the CMUCL programmers interpreted "present in the package" in the
description of :INTERNAL as meaning "directly present in the package".
I.e. specifying :INTERNAL will only match the symbols for which FIND-SYMBOL
would return :INTERNAL rather than :INHERITED.

>Now, what should
>        (do-symbols (x "FOO")
>          (print (multiple-value-list (find-symbol (symbol-name x) "FOO"))))
>print?
>
>ACL6:  (bar:zot :inherited)
>CLISP: (BAR:ZOT :EXTERNAL)
>CMUCL: (BAR:ZOT :EXTERNAL)

I think only ACL6 is correct.

>This means that (test-package-iterator "FOO"), defined in
>http://www.lisp.org/HyperSpec/Body/mac_with-package-iterator.html,
>will throw an error:
>        Symbol BAR:ZOT not found as :INHERITED in package FOO [(BAR:ZOT
>:EXTERNAL)]
>in CLISP and
>        Symbol BAR:ZOT not found as :EXTERNAL in package FOO [(BAR:ZOT
>:INHERITED)]
>in ACL6 (it works fine in CMUCL)
>
>So, what is going on here?
>What should (wpi :external :inherited) print?

It should be the same as (wpi :inherited), since FOO doesn't export any
symbols.

>What about do-symbols?

What about it?

-- 
Barry Margolin, ······@genuity.net
Genuity, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.