保存 Lisp 状态
我是 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
来自 ECL 手册:
(强调我的)看来,你对 ECL 不走运。但是,CLISP、CCL 和 SBCL 支持此功能,因此如果您需要它并且可以选择切换...请尝试其中一个。
From the ECL manual:
(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.
正如 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.)