如何查看Lisp(sbcl)中函数的定义? [英] How can I view the definition of a function in lisp (sbcl)?
问题描述
我使用sbcl+emacs+slime
.
我用Lisp编写了一个函数,
我使用C-c C-c
编译,但是我已经将其删除.
我找不到我想知道如何定义它.
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.
我尝试使用function-lambda-expression
,但是我得到了:
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!
感谢Vsevolod.
如果在repl
中定义了函数,则可以使用(descri #'function-name)
来获取定义函数的方式,但是如果我通过C-c C-c
对其进行定义,则只会得到source file
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
推荐答案
根据调试和优化的设置,您可能可以通过describe
来获取它:
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)))
您可以在Souce form
部分中看到定义.
You can see the definition here in the Souce form
part.
这篇关于如何查看Lisp(sbcl)中函数的定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!