From: Robert Goldman
Subject: stupid package question
Date: 
Message-ID: <6026@rex.cs.tulane.edu>
Is there a correct way to do the following in a file?

1)  make a package, P
2)  load a system into this package
3)  set some parameters of the system (symbols in the package)

I've been trying to do this in compiled lucid code, and find it
impossible.  The references to the symbols in (3), which were interned
in the existing package P, at the time when the file is compiled, now
cannot be found.  I don't understand why this should be so, since (in
step 1), I have created the package, and in step 2 interned the
symbols.  I even have a hazy understanding of why this might be a
difficult thing.  Of course, this file works perfectly when evaluated,
rather than compiled.

HOWEVER, it seems to me that this would be something a lot of people
would want to do, particularly in lisp-init files.  I suppose I could
have my lisp-init file load another file that simply does step 3
above, but that seems inelegant.  I'd be happy to have an interpreted
lisp-init file, but the interpreter is not so happy about this
(lucid's default behavior when asked to load a source file is to hang
pending user response -- not very good if one wants to start one's
lisp and go get a cup of coffee).

I realize that this is not the world's most significant problem, but
as is usual, the irritation created by this problem is inversely
proportional to its importance.  So I'd appreciate any enlightenment.

Best,
R
From: Kevin Gallagher
Subject: Re: stupid package question
Date: 
Message-ID: <26205@dime.cs.umass.edu>
    > Is there a correct way to do the following in a file?

    > 1)  make a package, P
    > 2)  load a system into this package
    > 3)  set some parameters of the system (symbols in the package)

The best thing to do is to create a separate file (in package "P") to
do the third step.  This is the cleanest and least likely to cause
you problems later on.

If you only have a few variables that you want to set you can do
something like:

  ;; This is exactly the same as (SETF P::*PARAMETER-ONE* 35)
  ;; except that package P need not need not exist when this
  ;; form is read.
  (setf (symbol-value (intern "*PARAMETER-ONE*" "P")) 35)

It's a bit ugly, and, generally, you should avoid using intern
unless you *really* need it.  This is the sort of situation where
you need it.

Also, not all lisps allow a package name as the second argument to
intern, they require the actual package.  In those cases you must do:

  (setf (symbol-value (intern "*PARAMETER-ONE*" (find-package "P")))
        35)

Which is even more opaque.

Kevin Gallagher