[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Argument lists



Perhaps we can try to converge on the argument-list business.  Nick
Gall's proposal seems to be the leading contender for a low-cost
standard way of finding out how a function may legally be called.  This
is an upward-compatible extension to the language:

---------------------------------------------------------------------------
(function-parameter <function>)

Takes one argument which must be a function, not a macro or special
form.

Returns the following six values:

1. Number of required parameters in the function's lambda list.
2. Number of optional parameters in the function's lambda list.
3. T if the function's lambda list contains the &REST lambda-keyword;
   NIL otherwise.
4. T if the function's lambda list contains the &KEY lambda-keyword;
   NIL otherwise.
5. A list of all keywords accepted by the function, in arbitrary order.
6. T if the function's lambda list contains the &ALLOW-OTHER-KEYS
   lambda-keyword; NIL otherwise.

If return value 4 is NIL, 5 and 6 must also be NIL.

---------------------------------------------------------------------------

Can everyone live with that?  If not, say so.

There seems to be little enthusiasm for REQUIRING that an implementation
supply the function's original argument list or the names of the
parameters, especially for compiled code.  There remains the issue of
whether we should provide a standard way of asking for additional,
internal argument list information if it is available.  Some
implementations would supply this information, others would not, and
others might supply it for some functions and not for others.

I personally believe that a standard format for getting at argument-name
information, if it is available, would be useful, but I don't like the
idea of returning the original lambda-list (or a copy of it).  The
problem is that the lambda-list contains default-value forms that can be
very complex and that would be confusing when taken out of context.  I'd
prefer something like the following, to be used in conjunction with
Function-Parameter as defined above:

---------------------------------------------------------------------------
(function-parameter-names <function>)

Takes one argument which must be a function, not a macro or special
form.

Returns two values:

1. A list containing the symbols naming the required, optional, and rest
   parameters, in order, if this information is available; NIL
   otherwise.
2. T if the list returned as value 1 is valid; NIL otherwise.
---------------------------------------------------------------------------

Would something like this be useful in the standard, or should we let
each implementation decide for itself wht format to use in providing
arglist info?

-- Scott