将任何Common Lisp结构对象保存到文件(可读)似乎相对简单,例如
(defun save-structure-object (object filename)
(with-open-file (stream filename :direction :output
:if-exists :supersede)
(with-standard-io-syntax (print object stream))))
但是,对于CLOS对象实例,Make clos objects printable in lisp处的帖子表示更复杂的配方。
首先,关于close-mop的评论是否与保存clos类实例的更简单方法有关?
第二,那里提供的代码是作为打印任何clos实例的通用实用程序提供的吗?
答案 0 :(得分:1)
Closer to MOP允许你在你所引用的帖子中避免危险的读取时间条件纠结。一般来说,使用许多人使用的OOTB解决方案比随机的特殊黑客更安全 - 您自己或其他人。
在closer-mop
出现之前,我写了自己的CLOS/MOP compatibility layer和CLOS object i/o。我建议您使用它代替您引用的SO答案中的代码。