[Ecls-list] Weird behavior with package variable named "STRING"

Juan Jose Garcia Ripoll lisp at arrakis.es
Thu Dec 1 07:36:04 UTC 2005


On Thu, 2005-12-01 at 16:15 +0100, Goffioul Michael wrote:
> Here's a piece of ECL session:
> 
> > (defpackage "A")
> #<"A" package>
> > (defpackage "B")
> #<"B" package>
> > (defvar a::string 261)
> STRING
> > (defvar b::string 262)
> STRING
> > a::string
> 261
> > b::string
> 261
> 
> As you can see, the "STRING" variable in package "B" has not the
> expected value. Is this normal? This does not happen with another
> variable name (I tried with "num" instead of "string").

If you try with NUMBER you will find similar behavior. The point is that
DEFPACKAGE has an implicit :USE statement which imports "COMMON-LISP"
package. If you do not want any symbol in the package use (defpackage
(:use))

> (defpackage "A")
#<"A" package>
> (symbol-package 'a::string)
#<"COMMON-LISP" package>
> (defpackage "B" (:use))
#<"B" package>
> (symbol-package 'b::string)
#<"B" package>

Juanjo





More information about the ecl-devel mailing list