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

1

7

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

Shennashensi answered 14/11, 2015 at 9:44 Comment(1)
It's not quite a duplicate, but it may answer your question: how do I jump to a function definition in emacs when using slime?. If you have the distribution source installed, that may work. implementations of lisp functions isn't a great question, but it might help, too.Dougdougal
D
13

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.

Daggna answered 15/11, 2015 at 6:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.