[slime-devel] Re: newbie questions related to sldb

Luke Gorrie luke at bluetail.com
Mon Aug 16 21:37:34 UTC 2004


Sundar Narasimhan <sundar at itasoftware.com> writes:

> Hi, Luke -- I wonder if there should be a "set-frame-in-repl"
> command..

This sounds like something that other people have wanted too, more or
less. We can look at it in the future, but it's a bit big to slip into
slime 1.0, which should go out in a week or two warts and all :-)

> Ok.. We have code that essentially does a (in-package :xyz) at the
> top of the file.

The modeline shows what SLIME thinks is the current package. You
should see "Slime:xyz", do you?

This is based on a text search for an in-package form, first backwards
then forwards. The modeline is updated on an idle timer just for
display purposes. Any evaluation/macroexpansion/etc will lookup the
package by search afresh each time.

An exception is popup buffers like apropos results. These inherit the
package that was current when they popped up (stored in a buffer-local
variable.)

Less-than-intuitively, if the current buffer's declared package
doesn't exist then the CL-USER package is used as a default. This "may
be difficult to construe as a feature."

> Unfortunately I have a habit of moving to a particular form, and
> then macro expanding it to see the code. When I do this in slime
> mode.. I get global variables and other things prefixed with
> common-lisp-user::. But when I actually cut-paste (macroexpand
> 'myform) or (macroexpand1 'myform) in the repl .. I don't get this
> .. any idea on what could be happening?

Can you reproduce this with a really simple/explicit example?

One possible explanation is:

  The macro was accidentally defined in the CL-USER package. It refers
  to the wrong symbols.

  You macroexpand it in a Lisp buffer belonging to a different package
  and the result is formatted with that package being *package*. The
  result thus includes common-lisp-user:: qualifiers.

  You then paste the form into (macroexpand '...) in the REPL. The
  REPL happens to be in the CL-USER package so it prints with that as
  *package* and the result has no package qualifiers.

I can't be sure without more information.

> On certain machines.. :) emacs would, if you had a line like so at the
> top of your file..
> ;;;-*- Mode: Lisp; Package: foo; -*-

SLIME currently works solely on text-search for an in-package form.

Note that those magic "file cookies" are meaningful in Emacs too, and
they can have awful side-effects. If the variable was in lowercase:

  -*- package: foo -*-

Then Emacs would create a buffer-local variable called `package'.
Unfortunately, that local variable could clobber dynamic bindings of
`package' when switching buffers, and thus accidentally rebind a local
variable some function was using!

Really disgusting, and this has happened somewhere in SLIME, and it
still can. Be careful of your magic file cookies :-)

Cheers,
Luke






More information about the slime-devel mailing list