2017-02-19 103 views
2

保存任何Common Lisp的結構對象到一個文件(可讀)似乎與像保存CLOS對象

(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實例的通用工具提供的嗎?

回答

1

Closer to MOP允許您避免參考文章中讀取時間條件的危險糾結。一般而言,使用許多人使用的OOTB解決方案比隨機特別攻擊(您自己或別人的攻擊)更安全。

之前closer-mop在旁邊,我寫我自己CLOS/MOP compatibility layerCLOS object i/o。我建議你用它來代替你參考的SO答案中的代碼。