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

Re: INTERN [Gall: Bug Report]



        !section  11.7      Nick Gall 85-03-20
        !version  Digital Press 1984
        !topic    INTERN's effect on an accessible symbol's owner.

                    As a verb, to `intern' a symbol in a package means to
                  cause the symbol to be interned (sic) in the package if
                  it was not already; this function is performed by the
                  function INTERN.  If the symbol was previously unowned,
                  then the package it is being interned in becomes its
                  owner (home package)...
                                                          CLRM Section 11.0 (pg. 172)

        I interpret this passage in the following way:

        ;; Current package is USER

        * (setf p1 (make-package 'p1 :use '()))
        {printed rep. of p1}

        * (import 'p1::xyzzy)
        T

        * (symbol-package 'xyzzy)
        {printed rep. of p1}

        * (unintern 'xyzzy p1)
        T

        * (symbol-package 'xyzzy)
        NIL         ;; At this point, xyzzy is an accessible uninterned symbol.

        * (intern "XYZZY")
        XYZZY
        :INTERNAL

        * (symbol-package 'xyzzy)
        {printed rep. of user}

        In other words, INTERN ensures that the symbol that it returns
        as its first value has a home package.

        Is this interpretation correct?

    I think the mention of accessible but unowned symbols on page 172 (in the
    discussion of home packages) shoots down your example.  The result of the
    last call to SYMBOL-PACKAGE is probably undefined.

I don't understand your response.  The mention of accessible but
unowned symbols on page 172 merely confirms the possibility of
accessible uninterned symbols.  I fully agree that such beasts
may exist.  In fact, I have annotated the above code to show that
BEFORE the intern is done, xyzzy is an accessible uninterned
symbol.

My contention is that the above call to INTERN should (according
to my interpretation of the CLRM and for practical reasons which
I will point out below) change xyzzy from an accessible
uninterned symbol into an interned symbol (simply by updating its
package cell).

    If the symbol was previously unowned, then the package it is
    being interned in becomes its owner (home package); but if the
    symbol was previously owned by another package, that other
    package continues to own the symbol.

This sentence strongly suggests to me that intern does affect
accessible uninterned symbols.

If intern does not update an accessible symbol whose package cell
contains NIL, there is NO WAY to change the home package of the
symbol.  I can't give it a new home!

Suppose I defun foo in the user package.  Then I decide that it
`belongs' in my tool package.  The best I can do now is

* (import 'foo 'tool)
T

* (unintern 'foo)
T

But whenever foo is printed, it will print as #:foo.  This is
unacceptable.