Re: symbold and packages

[email protected] Thu, 8 Jul 2004 17:14:41 -0700
Newsgroups gmane.lisp.allegro
Message-ID <[email protected]>
> Thanks, I cannot do this because I don't actually pass the symbol p
> directly (with 'p) but is read from a file that contains a list of
> these symbols and each one of these is passed as parameter to the
> function.

Perhaps the problem is that the function which reads the file is in one
package but you want the symbols in the file to read in as being in the
other package.  You can bind *PACKAGE* around the READ to cause the
symbols to read in whatever package you want.  For example:

(in-package "P2")

(with-open-file (strm "input.file" :direction :input)
  (let ((*PACKAGE* (find-package "P1")))
    (setq x (read strm))))

Now file "input.file" contains:

(A B C)

This, when the file is read, will cause the symbol P2::X to become
set to the value (P1::A P1::B P1::C) rather than to the value
(P2::A P2::B P2::C), as would happen if the read happens when the
variable *PACKAGE* is set to the P2 package.

Alternatively, you can put package prefixes on all your symbols in the
file.  Probably the keyword package would be best for that purpose.

Hope that helps.
 -Bob