views:

79

answers:

3

Have some way to save the REPL state of Common Lisp or Scheme?

Thanks

+2  A: 

This is implementation dependent however it is commonly possible to save an image. Note however some things that refer to external resources may not be saveable - for example the state of streams connected to files or execution state in threads (although there are I believe some implementations of scheme which do allow for saveable continuations). It is not part of the language itself.

John
+2  A: 

Your implementation has to support this. For instance, SBCL has (sb-ext:save-lisp-and-die), with two caveats:

  • The stack is unwound,

  • You can't continue afterwards (obviously).

Frédéric Hamidi
+1  A: 

Most Scheme implementations compile to either C or some other intermediary format, so I know of none that provide for saving the current image state. Most will compile binaries though, so if that's what you're really after read your implementation manual.

Common Lisp, on the other hand, usually provided this in an implementation-defined way. SBCL has the previously mentioned save-lisp-and-die function, and CCL has save-application. These are the only two Lisps I use, so if you're using another implementation, be sure to check the documentation.

If you'd like a how-to to see how this is done, here's one for SBCL. For CCL, check out the Apple Current Converter example. The tutorial there finishes with example steps on how to save out the resulting app bundle.

Edit: here's another, easier example for SBCL.

Shaun
There are many Scheme implementations which can save images. For example S48, SCM, MIT Scheme, ...
Rainer Joswig
I'll take your word for it, and stand corrected. It'd be great if you could throw some links up for reference for the next time a user comes here looking for an answer to this question.
Shaun