从 CCL 检索(加载)ed 源代码?
Retrieving (load)ed source code from CCL?
我用 CCL 调用了 (load "code.lisp")
,然后不小心删除了 code.lisp。有什么办法可以找回源码吗? CCL 是否在任何地方的内存中?
这是一个非常特殊的功能。这里只针对 Clozure CL。该代码在其他任何地方都不起作用。这在 CCL IDE 中对我有用。它检索某个包中 :internal
或 :external
符号的源代码。对于从其他包继承的符号,它不会这样做(你通常会从包 CL
或 CCL
中获得源代码,这有点太多了)。
(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
我用 CCL 调用了 (load "code.lisp")
,然后不小心删除了 code.lisp。有什么办法可以找回源码吗? CCL 是否在任何地方的内存中?
这是一个非常特殊的功能。这里只针对 Clozure CL。该代码在其他任何地方都不起作用。这在 CCL IDE 中对我有用。它检索某个包中 :internal
或 :external
符号的源代码。对于从其他包继承的符号,它不会这样做(你通常会从包 CL
或 CCL
中获得源代码,这有点太多了)。
(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