Subject: Re: Finding the arity of a function
From: Erik Naggum <erik@naggum.net>
Date: Tue, 18 Sep 2001 15:47:24 GMT
Newsgroups: comp.lang.lisp
Message-ID: <3209816844401584@naggum.net>

* Mathew Sanders
> Does anyone know of a function in lisp that given another function
> returns the arity?

  The arity of a function in Common Lisp is given by two values, not just
  one, the lower bound being the number of required arguments and an upper
  bound being the number of additional &optional arguments, and finally,
  may not be bounded except by sysetm limits on the number of &rest or &key
  arguments.  The various implementations have different ways to access
  this information, which is usually kept in some other place in addition
  to the code that checks for the correct number of arguments.

  I think LWW's choice of name for the accessor, function-lambda-list, is
  good, so this function will give you the same function portably bewteen
  LWW and Allegro CL:

#+allegro
(defun function-lambda-list (function)
  (excl:arglist function))

  Usually, the function describe will tell you about argument lists and
  other useful stuff, and in the free Common Lisp implementations, you can
  find out how they do that by looking at the source.

///