保存CLOS对象 [英] Saving CLOS objects

查看:93
本文介绍了保存CLOS对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将任何Common Lisp结构对象保存到文件(可读)似乎相对简单,

Saving any Common Lisp structure object to a file (readably) seems relatively straightforward with something like

(defun save-structure-object (object filename)
  (with-open-file (stream filename :direction :output
                                   :if-exists :supersede)
    (with-standard-io-syntax (print object stream))))

对于CLOS对象实例,该帖子位于使clos对象可打印成Lisp模式表示更复杂的配方。

For a CLOS object instance, however, the post at Make clos objects printable in lisp indicates a more complex recipe.

首先,有关close-mop的评论是否与保存clos类实例的更简单方法有关?

First, does the comment about closer-mop relate to a simpler approach to saving a clos class instance?

其次,这里提供的代码是否存在作为打印任何Clos实例的通用工具?

And second, is the code offered there presented as a general utility for printing any clos instance?

推荐答案

更接近MOP allo我们建议您避免在所引用的文章中出现阅读时间条件的危险纠缠。一般来说,使用许多人使用的OOTB解决方案要比随机的即席黑客(您自己或他人的黑客)安全。

Closer to MOP allows one to avoid the dangerous tangle of read-time conditionals in the post you refer to. Generally speaking, using an OOTB solution that many people use is safer than a random ad hoc hack - your own or someone else's.

closer-之前-拖把,我写了自己的 CLOS / MOP兼容层 CLOS对象I / O 。我建议您使用它而不是您参考的SO回答中的代码。

Before closer-mop was around, I wrote my own CLOS/MOP compatibility layer and CLOS object i/o. I suggest that you use it instead of the code in the SO answer you reference.

这篇关于保存CLOS对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆