Not sure if this is an emacs-SLIME issue or a CL issue or SBCL issue.
I've heard it said that the interactive nature of Lisp allows for changing a program while the program is running. Not knowing the specifics of what is meant by this, I tried the following, placing this in a separate file:
(defparameter repl-test-var 5)
(defun repl-test ()
(format t "repl-test-var is: ~a" repl-test-var)
(fresh-line)
(when (not (equal (read-line) "quit"))
(repl-test)))
Then I compile and run (repl-test)
and every time I press enter, I see the number 5
.
Without typing quit
at the REPL, I go back to my file and change the 5
to a 6
and compile again. Back at the REPL, pressing Enter still shows the 5
. If I type quit
and then run (repl-test)
again, now I see the 6
.
I have also tried loading as well as a combination of compile followed by loading using the SLIME shortcuts and they also have no effect until after I quit the running program and then start it again.
Is what I am trying to do either not possible or requiring another step in the code?
I realize it is a trivial example, but in more complex scenarios I may wish to do this.
It appears that your code is not being reloaded while the REPL is busy because your SBCL image is single threaded. You can determine that your SBCL is single threaded by checking that :sb-thread is not present in *features*. Threaded vs unthreaded is determined when SBCL itself is compiled, so to get the behavior you desire you will need to either acquire an SBCL binary with threads enabled or compile SBCL with threads enabled.
A lack of threads can get in the way of some benefits of interactive development (as in your test, or if you want to develop a web program that has a server component running in the same image) but it still leaves some benefits open. Some handy aspects of interactive development that don't require your program to be actively "doing" anything for you to enjoy them include that you only have to reload the parts of your program that you changed, that this reloading does not cause the program to dump the data it has loaded (as a restart might), and that the REPL can be used as a handy window into your program's state and behavior.