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

Using symbols (instead of their print names) in defpackage



There seems to be a `feature' in ACL; consider the following form:

(defpackage :x (:use :common-lisp) (:export a))

I would expect the symbol with the print name "A" to be created in 
the package named :x.  However, when this form is evaluated in a 
prestine acl, looks what happens:

--------------------------------
Allegro CL 4.0.1 [Sun4] (2/8/91)
Copyright (C) 1985-1991, Franz Inc., Berkeley, CA, USA
<cl> (find-symbol "A" :user)

NIL
NIL
<cl> (defpackage :x (:use :common-lisp) (:export a b))

#<The X package, 0 internal, 2 external>
<cl> (find-symbol "A" :user)

A
:INTERNAL
<cl> :pack :x

<cl> (find-symbol "A" :user)

COMMON-LISP-USER::A
:INTERNAL
<cl> (find-symbol "A" :x)

A
:EXTERNAL
<cl> :pack :user

<cl> (use-package :x)
Error: Using package `X' results in name conflicts for these symbols:
(B A)

Restart actions (select using :continue):
 0: unintern or shadow the conflicting symbols in the `COMMON-LISP-USER' package.
--------------------------------
In CLtL2 pg. 271 under (:export {symbol-name}*), it states:
Symbols with the specified names are located or created in the 
package being defined and then exported, just as with the function 
export. ...

On page 270 third paragraph, ... In every case, any option argument
called package-name or symbol-name may be a string or a symbol; if 
it is a symbol, only its print name matters, and not what package, 
if any, the symbol happens to be in.

The way I understand this is that a symbol with the print name "A" 
should be created in the package named :x, then that symbol should 
be exported.  It appears that acl is using the symbol and not it's 
print name.  There appears to be a similar problem with the export 
function as well.
--------------------------------
<cl> :pack
The COMMON-LISP-USER package is current.
<cl> (export '(a1 b1) :x)
Error: These symbols are not available in the X package:
   (A1 B1)

Restart actions (select using :continue):
 0: Import these symbols into the `X' package.
[1c] <cl>

--------------------------------
I would have expected, the symbols with print names "A1" and "B1" to 
be created in the package named :x.  Is this problem pervasive 
throughout the other package functions which also accept symbols or 
their print-names?

In general, what is the best way to refer to a symbol when defining 
the package?  Given that Allegro provides various case sensitivity 
modes, a symbol's print name is dependent upon the case sensitivity 
mode (unless ones always uses a vertical bar as symbol delimiters).

Thanks,
Darrell