保存 Lisp 状态

发布于 2024-12-08 22:06:41 字数 131 浏览 8 评论 0原文

我是 lisp 的初学者,有一个问题。 当我直接在 REPL 中编写一些代码(没有任何 .lisp 文件!)时,如何保存解释器的工作/状态以便下次恢复并继续工作?

(我正在使用 ECL)

谢谢!抱歉我蹩脚的英语;)

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

弃爱 2024-12-15 22:06:41

来自 ECL 手册

传统上,Common Lisp 实现提供了一个函数
保存转储中的所有数据
将 Lisp 进程运行到文件中。结果被称为 Lisp 图像
并可以运送到其他兼容版本
如今,对其运行的系统的控制较少
其中,Lisp 实现必须非常努力地转储内存映像
然后能够加载并执行它们。

ECL 选择完全避免此过程。相反,我们设想
五种不同的便携式模型用于构建和交付您的程序。
表 1.1 中描述的模型列举了不同类型的
ECL 可以移植生成的文件。为了获得其中一项或多项
表中提到的产品,您可以使用低级 API
第三部分中描述。但是,我们推荐一种更简单的方法
使用系统定义文件来描述您的结构
项目并让 ECL 为您构建所需的目标。这种方法是
在以下部分中进行了描述。

(强调我的)看来,你对 ECL 不走运。但是,CLISPCCLSBCL 支持此功能,因此如果您需要它并且可以选择切换...请尝试其中一个。

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.

后知后觉 2024-12-15 22:06:41

正如 Dirk 提到的,您可以在许多 Lisp 实现中保存图像。然而,虽然这满足您规定的要求,但将代码保存在图像中并不是一个好主意,因为这样就更难或不可能编辑。能够获取函数的源代码是一项可选功能(即使它存在,您也会丢失注释和格式),并且许多其他类型的定义根本无法以标准方式恢复。

另一方面,如果您在 REPL 上进行了详细的设置或编译时间较长,那么使用图像来保存和恢复您的工作是没问题的。

(有些系统,特别是 Smalltalk,确实促进在图像中编辑代码,并具有支持这一点的编辑和导出工具,但标准化的 Common Lisp 却没有,我也不知道有任何现代 CL 实现可以做到这一点。)

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文