Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 205
yonh Avatar asked Nov 14 '15 09:11

yonh


1 Answers

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 Source form part.

like image 135
Vsevolod Dyomkin Avatar answered Nov 04 '22 01:11

Vsevolod Dyomkin