Subject: Re: temporarily setting a package
From: Erik Naggum <clerik@naggum.no>
Date: 1998/04/13
Newsgroups: comp.lang.lisp
Message-ID: <3101492852846049@naggum.no>


* Sam Steingold
| Erik's solution for the :key/#'reduce ACL problem starts with
| (in-package :franz) and ends with (in-package :user).

  huh?  it doesn't end with (in-package :user) in any version I can find
  that I have posted.  where did you get one that did?

  the purpose of IN-PACKAGE is to ensure that symbols are interned in a
  known package so the compiler can make certain optimizations and the user
  of a file can live a less interesting life.  it is not for interactive
  use.  (in Allegro CL, you use the top-level command :PACKAGE for that.)

  you should just stuff my advice code in a file, perhaps compile it, and
  then load it.  it should not be prefixed onto other source code, which is
  what it appears that you're doing.  LOAD will bind *PACKAGE* across
  loading, so it can be changed during loading.  COMPILE-FILE will do the
  same.

| what if I wasn't in :user?

  the obvious solution is not to invoke IN-PACKAGE when you need the value
  of the same binding of *PACKAGE* afterwards.  which, again, LOAD takes
  care of for you: you get the same binding of *PACKAGE* after LOAD as
  before, because the one that may have been changed inside the loaded
  object is a different binding.

  matter of fact, (in-package :franz) does only a little more than

(eval-when (:compile-toplevel :load-toplevel :execute)
  (setq *package* :franz))

  which works because *PACKAGE* is bound by LOAD and COMPILE-FILE.
  
#:Erik
-- 
  religious cult update in light of new scientific discoveries:
  "when we cannot go to the comet, the comet must come to us."