I'm trying to create just a basic package called "a" (to learn) with asdf which I've already defined in package.lisp, and my main file a.lisp starts with:
(in-package :a)
...
If I'm developing my module I'd just like to run eval the whole buffer into the SLIME REPL by doing M-x slime-eval-buffer or something, but that does not happen, after running that command I'm still at the cl-user package:
;;; from a.lisp
A> (in-package :a)
#<PACKAGE "A">
CL-USER> <--- should have stayed in A>
If however I paste the whole code in the SLIME REPL myself it already works. Pasting lots of code over and over is not nice at all though for interactive development.
Can you help? Do you have suggestions for what I'm getting wrong, or how you usually cope with this instead?
Thank you.
It doesn't work like that. The in-package
form is an instruction for the reader, so that the forms in the buffer after that are read in that package. In fact, when you do a C-c C-c
(slime-compile-defun), it will look for the preceding in-package
form regardless of whether that was evaluated or compiled somehow.
It would be a source of confusing errors otherwise, since you could (and frequently would) accidentally compile things in the wrong package because of some changed interaction order.
In order to switch the package in the REPL, you can execute an in-package
form there, or you can use the SLIME shortcut C-c ~
from the buffer (which also switches the current directory).