Is there a way to go back to last state of the runtime? In short, save the runtime and reload it. But the core image is too big (I'm making a small game :-), so I come up with an idea, save some important data, and start running at certain line (maybe also the stack info).
For example:
(defun save ()
_do-some-magic-to-save-the-state-and-then-exit_)
(defvar data (list 'a 'b 'c)) ; important data
(format t "Hello ")
(save)
(format t "World!~%")
Next time, the software can start at the point where it stopped.
$ software
Hello $ software
Hello $ software --load saved_state
World!
But I don't know how to do this in Common Lisp at all... Could someone please give me some ideas?
How this works depends on the Common Lisp implementation. Consult the manual:
CLISP -> Saving an Image
several other implementations ...
You might want to try implementing Alex Warth's Worlds (chapter 4 of his thesis). This would allow you to "sprout" a new World, run your computation in it, and either periodically commit the changes in the child world to the parent world, or abort and roll back to the parent's state. This is like an infinite undo, but you can sprout multiple worlds/chains of undo.