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

Re: intern



	
    Date: Tue, 11 Feb 86 12:33:45 pst
    From: hpfclp!diamant@hplabs.ARPA
    To: hplabs!common-lisp@su-ai.ARPA
    Subject: Re: intern
    
      From: hplabs!NGALL@G.BBN.COM
	    
	  My question is: does INTERN (the function) always "intern" (the
	  verb).  Also, are there any other functions which "intern," such
	  as import, for instance.  Specificially, should INTERN set the
	  home package of an uninterned symbol?
	  
      I asked this question a while back (too bad the archives are so hard
      to access!).  My impression was that there was a consensus that IMPORT
      is the function that is responsible for "updating" the package-slot of
      an uninterned symbol (since IMPORT is the only function that can put a
      SYMBOL in a package).
      
      Guy Steele sent out a list of proposed "clarifications" a few months
      ago (also in the archives).  The clarification for IMPORT was: "If
      symbol has no owner, its package cell is updated."
      
	    -- Nick
      
    
    ...

    Thanks for the clarification on IMPORT.  I did have a copy of the
    clarifications, but hadn't looked them over carefully enough.  I am
    certainly satisfied by the new definition of IMPORT, but something
    still bothers me about INTERN.  As the reason for having import be
    the only function responsible for updating the package slot, you claim that
    IMPORT is the only function that can put a SYMBOL in a package.  By this,
    do you mean an already existing symbol, or any symbol?  Obviously, if
An already existing symbol.
    I type (intern "FOO"), I will put the symbol FOO in the current package (if
    it wasn't already available).  If you mean an already existing symbol,
    isn't that equivalent to the question I already asked?
I'm not sure wwhich question you are refering to.
    I'm not trying
    to be picky -- I just don't understand the motivation for restricting
    INTERN from setting the home package.  On page 172, CLtL says (for the
Neither do I.  (And I don't think you're being picky, keep the
comments coming!)
    function INTERN):  "If the symbol previously was unowned, then the package
    it is being interned in becomes its owner (home package); but if the symbol
    was previously owned by another package, the other package continues to
    own the symbol."  To me, that seems to strongly suggest that INTERN would
    have to set the home package on a symbol which doesn't CURRENTLY have a
    home package.  As I said before, this creates a problem for the definition
Unfortunately, most implementors seem to have ignored this passage.
    of FIND-SYMBOL since it is defined to be identical to INTERN except that
    it can't create a new symbol.  Consider:
    
    (let ((x (intern "FOO")))
      (import x (find-package "BAR"))
      (unintern x)
      (find-symbol "FOO" (find-package "BAR")))
      ;; the defn. in CLtL would imply that x would now be homed in BAR.
    
In my first reply, I forgot about good old UNINTERN, which can make an
interned symbol homeless (as in your example).  So I was making the
point that if one "fixed" import, one could never get homeless
interned symbols.  Wrong.

I think the attitude at the time was that IMPORTing a homeless symbol
(e.g., a GENSYMed symbol) was the only "straightforward" way that an
interned symbol could be left homeless, i.e., it is the only way
"novice" CL user's could "easily" cause such an inconsistency.  The
case of UNINTERN a symbol from its home package when it is also
present in other packages, was considered a pathological case (it is
even mentioned in the description of UNINTERN), and not worth the
trouble of having INTERN deal with.  So the passage on 172 was to be
removed (Guy, this is not in your list of clarifications.) and the
wording for IMPORT changed as I mentioned previously.

As far as FIND-SYMBOL is concerned, I think the "identical behavior"
wording was used because the passage on pg. 172 as overlooked.  To me,
the idea behind find-symbol is that it is identical to INTERN except
that it does not cause ANY side-effects (incl. fixing the package
slot).

What I would like to see is the following:

1. Leave the stipulation on page 172 that INTERN fix-up the package
slot of an interned symbol.

2. Refer to pg. 172 in the def. of INTERN.

3. Make IMPORT also fix up the package slot.

4. In UNITERN, after warning about homeless interned symbols, cf.
IMPORT for fixing things up.

5. Make clear that FIND-SYMBOL has NO SIDE EFFECTS.  And point out
that it is the only way of mapping a name to a homeless interned
symbol.

How 'bout it?!