开发者

Saving lisp state

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 ;)


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.


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.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜