Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How many arguments does a function take?

How can i get a lambda list specification of a some function parameters, or at least a number of arguments it takes?

For example:

(defun a (a b) )
(get-arg-list #'a) ;-> '(a b)
like image 880
Necto Avatar asked Dec 05 '25 20:12

Necto


2 Answers

Common Lisp provides the function FUNCTION-LAMBDA-EXPRESSION which may be able to recover the source expression, which then includes the lambda list.

LispWorks has defined a function FUNCTION-LAMBDA-LIST which returns the arglist.

Many other implementations have some form of ARGLIST function in some internal package.

Many Common Lisp users use SLIME, a very clever editor extension for the GNU Emacs editor. It has a backend for Common Lisp called SWANK. The SWANK sources provide all kinds of interfaces to the various Common Lisp implementations, including getting the arglist of functions.

like image 71
Rainer Joswig Avatar answered Dec 09 '25 21:12

Rainer Joswig


This is implementation specific, but this CLHS function might get you started - http://clhs.lisp.se/Body/f_descri.htm

like image 25
malkia Avatar answered Dec 09 '25 21:12

malkia