As you're rummaging around through the dynamic state of the running system, you'll discover changes that need to be made, and you might discover them absolutely anywhere. Sure, you could always kill the running system, make the change to the sources, and rebuild the system, but that's exactly what we're trying to avoid.
Consequently, old Lisp and Smalltalk systems are allergic to restrictions on runtime changes. Loosely speaking, if I find something I can't change while my program is running, that restriction is a bug in my development environment.
Old systems like this will discourage certain kinds of changes because they're usually ill-advised, but will not forbid them, because forbidding them is anathema.
As an example, several Common Lisps implement package locks on certain system packages. A package lock prevents you from changing the definitions of system-defined constructs.
But it's Lisp, so it doesn't really prevent the change. It just makes it more inconvenient. You have to say "Mother, may I?" first, which gives you the opportunity to soberly consider whether making that specific change is really really what you want to do.
This is about the development phase more than the production phase. Do something like this (directly in the REPL or in a buffer as mikelevin has described doing elsewhere):
(defparamater *db* (connect-to-test-db))
(query-db *db* (make-query some-query-description))
;; see that it pulls out the desired record
(let ((record (query-db *db* (make-query sqd)))
(update-record record)
(write-to-db *db* record)) ;; update the entry
;; rerun the query above to see that things changed as expected
;; rewrite that let as a defun:
(defun make-update-to-some-record (sqd db)
(let ((record ...))
...))
;; test that it works
(make-update-to-some-record sqd *db*)
;; see that it does in fact do the same as the let above.
;; move that to a permanent source file, and build it
;; into the system.
;; move tests into test file.
;; repeat with next feature/task
The functions run in the REPL are stateful, but we aren't careless about what they're touching.NB: You can connect to production environments. You can even connect to live, production lisp images. This could be useful for: profiling real-world activity, debugging real-world problems, applying hot-fixes. But especially that last one should be done carefully, and ought to have been validated using a test environment first.
Turn the testing code into unit test as I go along.
Rinse. Repeat.
For me, the whole point of the repl is that I want to build something incrementally, interactively, building it a little at a time by making small changes to it. I want it in memory, running and responding to my changes as I make them. Put this here; put that there. Change that around. Let me look at it; nope. Put that back where it was. Now add this.
If the repl is stateless then the whole purpose is defeated.