首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从CCL中检索(加载)ed源代码?

从CCL中检索(加载)ed源代码?
EN

Stack Overflow用户
提问于 2015-04-08 04:04:49
回答 1查看 151关注 0票数 4

我用CCL打电话给(load "code.lisp"),然后意外地删除了code.lisp。有什么方法可以让我检索源代码吗?CCL在任何地方都有记忆吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-04-08 07:51:03

这是一个非常特殊的功能。这里只提供Clozure CL。代码在其他任何地方都不起作用。这在CCL IDE中适用于我。它检索特定包中属于:internal:external的符号的源代码。对于从其他包继承的符号,它不会这样做(然后,您通常会从包CLCCL获得源代码,这有点过了)。

代码语言:javascript
复制
(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)))))))))

正如您所看到的,它可以检索自身(以及更多):

代码语言:javascript
复制
? (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
票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29505734

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档