Saving lisp state

与世无争的帅哥 提交于 2019-12-05 11:48:31

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!