[slime-devel] Re: in-package at REPL?

Luke Gorrie luke at bluetail.com
Thu Jul 15 11:32:42 UTC 2004


Peter Seibel <peter at javamonkey.com> writes:

> Can someone explain the basic theory of how SLIME thinks about
> packages?

The main thing is that the "current package" is determined by Emacs
state, not by *PACKAGE*. In a source buffer the current package is
determined by searching backwards for the nearest IN-PACKAGE and in
the REPL it's determined by looking at the local variable that you
just defined. :-)

When Emacs makes an RPC it includes the package name in the
request. The Lisp side finds the package and binds it to
*BUFFER-PACKAGE* and then uses it in the appropriate ways, e.g. as
*PACKAGE* when reading/eval'ing code from the user.

One issue is when you evaluate code in the REPL that reassigns
*PACKAGE*, e.g. calling IN-PACKAGE, you want that to change the
current REPL package. We detect these assignments specially with some
code in SWANK::EVAL-REGION and send a (:new-package FOO) update
message to Emacs.

Another complication is that code you enter in the REPL will be
evaluated in an environment that has a dynamic binding of *PACKAGE*
and various other things (e.g. standard streams), so you can't change
their global bindings with SETQ.

That help any?






More information about the slime-devel mailing list