Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!think!barmar From: barmar@think.COM (Barry Margolin) Newsgroups: comp.lang.lisp Subject: Re: Problems with Lisp Packages Keywords: Packages, Constants Message-ID: <36624@think.UUCP> Date: 23 Feb 89 07:31:54 GMT References: <117@bosco.dit.upm.es> Sender: news@think.UUCP Reply-To: barmar@kulla.think.com.UUCP (Barry Margolin) Organization: Thinking Machines Corporation, Cambridge MA, USA Lines: 38 In article <117@bosco.dit.upm.es> ibm@bosco.UUCP (Ignacio Bellido Montes) writes: > (DEFUN FOO (X) > (COND ((EQUAL (CAR X) 'YES) ... ) > ((EQUAL (CAR X) 'NO) ... ) > (T (PRINT 'ERROR))) > ) > > When the current package is the same where the function is defined, >the function is well evaluated. But when I use the function from another >package, using (PACKAGE-FOO::FOO), the predicate EQUAL fails. The definition of EQUAL specifies that symbols are EQUAL if and only if they are EQ. Therefore, if (CAR X) is a symbol in a different package from the one where FOO was defined, the EQUAL will return NIL. If you just want to compare the names of the symbols, not the actually identities, you should use STRING-EQUAL. > I stepped the function, but the only thing I saw is that the constants >YES or NO, are not qualified by the interpreter with the package identifier. I'm not sure what you're saying here. Which symbols aren't being qualified, the ones in the function or the ones in the parameter? If it's the ones in the function, then perhaps the symbols have been imported into the other package (but then the EQUAL should succeed). To clear up some possible confusion: the interpreter doesn't do anything with packages. Packages are only used by READ and PRINT. The package of a symbol you type is going to be whatever package was current at the time you typed it. If that's different from the package that was current when the function was defined, then you'll get different symbols. Barry Margolin Thinking Machines Corp. barmar@think.com {uunet,harvard}!think!barmar