我用CCL调用(加载“code.lisp”),然后意外删除了code.lisp.有没有办法让我检索源代码? CCL在内存中有没有它? 这是一个非常特殊的功能.这里仅适用于Clozure CL.该代码无法在其他任何地方使
(defun retrieve-source-code (&optional (package *package*))
(do-symbols (s package)
(multiple-value-bind (symbol where)
(find-symbol (symbol-name s)
package)
(declare (ignore symbol))
(when (member where '(:internal :external))
(let ((ds (find-definition-sources s)))
(when (and ds (listp ds))
(loop for (nil sn) in ds
for snt = (source-note-text sn)
when snt do (progn
(terpri)
(princ snt)
(terpri)))))))))
如您所见,它可以检索自己(以及更多):
? (retrieve-source-code)
(defun retrieve-source-code (&optional (package *package*))
(do-symbols (s package)
(multiple-value-bind (symbol where)
(find-symbol (symbol-name s)
package)
(declare (ignore symbol))
(when (member where '(:internal :external))
(let ((ds (find-definition-sources s)))
(when (and ds (listp ds))
(loop for (nil sn) in ds
for snt = (source-note-text sn)
when snt do (progn
(terpri)
(princ snt)
(terpri)))))))))
NIL
