From: Martin Simmons
Subject: Should SHADOWING-IMPORT make an external symbol internal?
Date: 
Message-ID: <1003257674.831063@itn>
The ANSI CL spec says that shadowing-import is like import but different.  Then
it says that "shadowing-import inserts each of symbols into package as an
internal symbol...".  Does anyone think the "internal" part is supposed to be a
difference compared to import, i.e. if the same symbol is already external then
should it become internal?

(defpackage "FOO" (:intern "BAR"))
(defpackage "FOO2" (:shadowing-import-from "FOO" "BAR") (:export "BAR"))

(find-symbol "BAR" "FOO2")
=> FOO::BAR, :EXTERNAL

(shadowing-import 'FOO::BAR "FOO2")

(find-symbol "BAR" "FOO2")
=> FOO::BAR, ?

--
Martin Simmons, Xanalys Software Tools
······@xanalys.com
rot13 to reply

From: Kent M Pitman
Subject: Re: Should SHADOWING-IMPORT make an external symbol internal?
Date: 
Message-ID: <sfw1yk3o090.fsf@world.std.com>
"Martin Simmons" <······@xanalys.com> writes:

> The ANSI CL spec says that shadowing-import is like import but
> different.  Then it says that "shadowing-import inserts each of
> symbols into package as an internal symbol...". 

IMPORT has similar verbiage, actually.

> Does anyone think
> the "internal" part is supposed to be a difference compared to
> import,

No.  (Be sure to read my remarks to the end here, since I had a kind of
guess/revelation as to what the real issue is about halfway through
writing this.)

> i.e. if the same symbol is already external then should it
> become internal?

It should DEFINITELY be only internal. It can easily be exported if
that's needed.  If it were not made internal by default, how would 
you repair that?

SHADOWING-IMPORT's purpose is to break ties, not to dictate interfaces.

I have lots of interfaces in my code that import external symbols of one
package to become internal symbols of another.  Consider a package that
implements an imbedded language 
 
 (defpackage "AUTOMOBILE-LISP"
   (:use "CL" "PONTIAC" "TOYOTA")
   (:shadowing-import-from "CL" "CAR")
   (:export "FIRST" "REST" ;*not* CAR and CDR 
            "AUTO"         ;*not* CAR
            ...etc.))

In other words, I might want to have some symbol availble for internal use
but still not pass it through.

> (defpackage "FOO" (:intern "BAR"))
> (defpackage "FOO2" (:shadowing-import-from "FOO" "BAR") (:export "BAR"))
> 
> (find-symbol "BAR" "FOO2")
> => FOO::BAR, :EXTERNAL
> 
> (shadowing-import 'FOO::BAR "FOO2")
> 
> (find-symbol "BAR" "FOO2")
> => FOO::BAR, ?

Oh, I see what your problem is.

My personal reading of that would not have been "it's supposed to force the
status back to :INTERNAL" but "rather it doesn't promote the thing beyond
:INTERNAL of its own accord".  I believe what it is trying to safeguard 
against is:

 (defpackage "TRUTH"
   (:use)
   (:export "YES" "NO"))

 (defpackage "PORTUGUESE-CONTRACTIONS"
   (:use)
   (:export "DO" "DA" "NO" "NA" "NUM" "NUMA"))

 (defpackage "ALPHA"
   (:use "CL")
   (:import-from "TRUTH" "YES" "NO"))

 (defpackage "BETA"
   (:use "CL" "PORTUGUESE-CONTRACTIONS" "TRUTH")
   (:shadowing-import-from "CL" "DO")
   (:shadowing-import-from "TRUTH" "NO")
   (:export "YES" "NO"))

In this case, the question would be whether 
 (find-symbol "NO"  "CL")    => CL:NO, :EXTERNAL
 (find-symbol "YES" "ALPHA") => TRUTH:YES, :INTERNAL
 (find-symbol "DO"  "BETA")  => CL:DO, :INTERNAL
 (find-symbol "NO"  "BETA")  => TRUTH:NO, :EXTERNAL
 (find-symbol "DA"  "BETA")  => PORTUGUESE-CONTRACTIONS:DA, :INTERNAL
From: Martin Simmons
Subject: Re: Should SHADOWING-IMPORT make an external symbol internal?
Date: 
Message-ID: <1003431166.553808@itn.cam.harlequin.co.uk>
"Kent M Pitman" <······@world.std.com> wrote in message
····················@world.std.com...
> Oh, I see what your problem is.
>
> My personal reading of that would not have been "it's supposed to force the
> status back to :INTERNAL" but "rather it doesn't promote the thing beyond
> :INTERNAL of its own accord".

Thanks, that is what I was hoping.


>                   I believe what it is trying to safeguard
> against is:
>
>  (defpackage "TRUTH"
>    (:use)
>    (:export "YES" "NO"))
>
>  (defpackage "PORTUGUESE-CONTRACTIONS"
>    (:use)
>    (:export "DO" "DA" "NO" "NA" "NUM" "NUMA"))
>
>  (defpackage "ALPHA"
>    (:use "CL")
>    (:import-from "TRUTH" "YES" "NO"))
>
>  (defpackage "BETA"
>    (:use "CL" "PORTUGUESE-CONTRACTIONS" "TRUTH")
>    (:shadowing-import-from "CL" "DO")
>    (:shadowing-import-from "TRUTH" "NO")
>    (:export "YES" "NO"))
>
> In this case, the question would be whether
>  (find-symbol "NO"  "CL")    => CL:NO, :EXTERNAL
>  (find-symbol "YES" "ALPHA") => TRUTH:YES, :INTERNAL
>  (find-symbol "DO"  "BETA")  => CL:DO, :INTERNAL
>  (find-symbol "NO"  "BETA")  => TRUTH:NO, :EXTERNAL
>  (find-symbol "DA"  "BETA")  => PORTUGUESE-CONTRACTIONS:DA, :INTERNAL

Hmm, is NO a CL external in your Lisp?!  Also, I get "DA" as :INHERITED in
"BETA", not :INTERNAL.

--
Martin Simmons, Xanalys Software Tools
······@xanalys.com
rot13 to reply
From: Kent M Pitman
Subject: Re: Should SHADOWING-IMPORT make an external symbol internal?
Date: 
Message-ID: <sfwpu7kvhmc.fsf@world.std.com>
"Martin Simmons" <······@xanalys.com> writes:

> Hmm, is NO a CL external in your Lisp?!

Oops.  Hey, I was making these up on the fly.  I guess I should have used
TRUTH:YES for that example.  Consider that I put a few errors in there to make
sure you were reading. ;-)

> Also, I get "DA" as :INHERITED in "BETA", not :INTERNAL.

Drat. Yeah. FWIW, I *hate* that stupid inherited/internal distinction,
and periodically make stupid program errors as a result of this.  I
understand what it's about but I think it's misguided. I'd rather
inheritance information were passed orthogonally to the
internal/external distinction.  (That is, I think you should really
get back :internal/:external and present-p, and that four states should
be possible.  That there are 3 seems weird to me.)