functionlambdaargumentscommon-lispsbcl

Getting function arglist in SBCL Lisp


In SBCL when I describe a lambda I get a bunch of detail:

* (setf f (lambda (a b) (* a b)))
#<FUNCTION (LAMBDA (A B)) {535B3C3B}>                                                                                                               
* (describe f)
#<FUNCTION (LAMBDA (A B)) {535B3C3B}>
 [compiled function]
Lambda-list: (A B)
Derived type: (FUNCTION (T T) (VALUES NUMBER &OPTIONAL))
Documentation: T                                                                                                                                                 
Source form: (LAMBDA (A B) (* A B))                                                                                                                            

How can I access these objects? In particular, I want to access the lambda-list.

Thanks!


Solution

  • You can use FUNCTION-LAMBDA-EXPRESSION to get the function's source code. The lambda-list will be the second element of this.

    * (second (function-lambda-expression f))
    (A B)