Q:

Lisp: Inspect function determine its required parameters

In Python, I can do this:
>>> def foo(x,y,z=1):
    return x+y*z

>>> foo.func_code.co_varnames
('x', 'y', 'z')
>>> foo.func_defaults
(1,)

And from it, know how many parameters I must have in order to call foo().  How can I do this in Common Lisp?

A:

Most implementations provide a way of doing this, but none is standardized.  If you absolutely need it, Swank (the Common Lisp part of SLIME) has a function called swank-backend:arglist that, as far as I can see, does what you want:
CCL> (swank-backend:arglist 'if)
(TEST TRUE &OPTIONAL FALSE)
CCL> (swank-backend:arglist 'cons)
(X Y)
CCL> (swank-backend:arglist (lambda (a b c &rest args)))
(A B C &REST ARGS)

I'm not sure you can rely on it remaining available in the future, though.

