从CCL检索(加载)源代码? [英] Retrieving (load)ed source code from CCL?

查看:142
本文介绍了从CCL检索(加载)源代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用CCL调用了(load "code.lisp"),然后不小心删除了code.lisp.我有什么办法可以检索源代码? CCL可以在任何地方将其存储在内存中吗?

I called (load "code.lisp") with CCL, then accidentally deleted code.lisp. Is there any way for me to retrieve the source code? Does CCL have it in memory anywhere?

推荐答案

这是一个非常特殊的功能.仅适用于 Clozure CL .该代码将无法在其他任何地方使用.这对我在CCL IDE中有效.它检索某个程序包中:internal:external的符号的源代码.对于从其他程序包继承的符号则不这样做(然后您通常会从程序包CLCCL获得源代码,这有点太多了.)

That's a very special functionality. Here only for Clozure CL. The code won't work anywhere else. This works for me in the CCL IDE. It retrieves the source code of symbols who are :internal or :external in a certain package. It doesn't do that for symbols which are inherited from other packages (you would then often have the source code from the package CL or CCL, which is a bit too much).

(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)))))))))

如您所见,它可以检索自身(以及更多):

As you can see, it can retrieve itself (and more):

? (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检索(加载)源代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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