Saving lisp state
Asked Answered
M

2

4

I am a beginner in lisp and have a question. When I writing some code directly in REPL (without any .lisp file!), how can I save my work/state of the interpreter to restore it next time and continue working?

(I am using ECL)

Thanx! And sorry for my broken english ;)

Muire answered 7/10, 2011 at 10:51 Comment(0)
S
6

From the ECL manual:

Tratidionally, Common Lisp implemenations have provided a function to save the dump all data from a running Lisp process into a file. The result was called the Lisp image and could be shipped to other version compatible implementations.Nowadays, having less control of the systems it runs in, a Lisp implementation must work very hard to dump memory images and be able to load and execute them afterwards.

ECL has chosen to avoid this process entirely. Instead, we conceive five different portable models for building and shippin your programs. The models, described in Table 1.1, enumerate the different kinds of files that ECL can portably produce. To get one or more of the products mentioned in the table, you may resort to a low level API described in Part III. However, we recommend a simpler way based on using System Definition Files to describe the structure of your project and let ECL build the desired target for you. This approach is described in the following sections.

(emphasis mine) so it seems, you are out of luck with ECL. However, CLISP, CCL, and SBCL support this feature, so if you want it and if switching is an option... Give one of those a try.

Snowflake answered 7/10, 2011 at 11:3 Comment(1)
Thank you, Dirk! I will try one of the suggested impl.Muire
W
1

As Dirk mentions, you can save an image in many Lisp implementations. However, while this meets your stated requirements, it is not a good idea to keep your code only in an image, because it then is harder or impossible to edit. Being able to get the source code of a function is an optional feature (and even if it exists, you lose comments and formatting), and many other types of definitions cannot be recovered in standard ways at all.

On the other hand, it's fine to use an image just to save and resume your work if you have elaborate setup at your REPL or a long compile time.

(Some systems, notably Smalltalk, do promote editing code within the image, and have editing and export facilities to support this, but Common Lisp as standardized does not, nor do I know of any modern CL implementation which does.)

Widmer answered 7/10, 2011 at 20:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.