How can I view the definition of a function in lisp (sbcl)?

ε祈祈猫儿з 提交于 2019-12-22 08:48:20

问题


I use sbcl+emacs+slime.
I writing a function in lisp, I use C-c C-c compile, but i've already deleted it.
I can't find it. I want to know how I define it.

I tried use function-lambda-expression, but I get this:

(function-lambda-expression #'b)
T
B

I hope someone can give me some help.Thanks very much in advance!


Thanks Vsevolod. If function define in repl, i can use (descri #'function-name) get how i define the function, but if i through C-c C-c define it, i just get source file

My attempt


回答1:


Depending on your settings for debug and optimization you may be able to get it via describe:

CL-USER> (defun f (a) (print a))
F
CL-USER> (describe #'f)
#<FUNCTION F>
  [compiled function]

Lambda-list: (A)
Derived type: (FUNCTION (T) (VALUES T &OPTIONAL))
Source form:
  (SB-INT:NAMED-LAMBDA F
      (A)
    (BLOCK F (PRINT A)))

You can see the definition here in the Souce form part.



来源:https://stackoverflow.com/questions/33707068/how-can-i-view-the-definition-of-a-function-in-lisp-sbcl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!