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

New, improved FUNCTION-TYPE-KEY-NAME proposal



Issue:         FUNCTION-TYPE-KEY-NAME
References:    CLtL p.47-48, 61
Category:      CLARIFICATION, CHANGE
Edit history:  Version 1, 23-Nov-1987 Sandra Loosemore
	       Version 2, 15-Jan-1988 Sandra Loosemore 
	           (from comments by Kent Pitman)
Related issues: FUNCTION-TYPE-REST-LIST-ELEMENT


Problem description:

The FUNCTION type specifier list is provided to allow declaration of
function argument types and return value types.  This type specifier
uses a syntax similar to the usual lambda list syntax to specify which
types go with which lambda list variables.  However, there is a problem
with &KEY lambda variables because CLtL does not specify how the types 
specified in the FUNCTION declaration are matched up to either the actual 
arguments passed to the function, or the lambda variables in the function 
definition (since the ordering of keyword arguments is arbitrary).

Proposal (FUNCTION-TYPE-KEY-NAME:SPECIFY-KEYWORD):

(1) Specify that the &KEY parameters in a FUNCTION type specifier lambda
list should be supplied as lists of the form (<keyword> <type>).  The
<keyword> must be a valid keyword-name symbol.

(2) Allow &ALLOW-OTHER-KEYS to appear in a FUNCTION type specifier lambda
list.


Test Case:

The type of the function MAKE-LIST could be declared as:

   (FUNCTION MAKE-LIST ((INTEGER 0) &KEY (:INITIAL-ELEMENT T)) LIST)


Rationale:

(1) This specifies a direct correspondence between the argument type and
its matching keyword.  All of the information is in one place, and the user
does not have to remember (or even know) the order in which &KEY arguments
appear in the actual function definition.

(2) This is probably an oversight in the original specification.


Current practice:

Many Common Lisp implementations currently ignore FUNCTION type
declarations.  The situation regarding type specifications for keyword
arguments is so ambiguous that few users attempt to use them.


Cost to Implementors:

Implementations that ignore the FUNCTION type specifier or keyword arguments
in a FUNCTION type specifier may continue to do so.  This proposal should
not involve massive amounts of code to be rewritten.


Conversion Cost:

Because the current situation is so ambiguous, FUNCTION type specifiers and
particularly the specification of keyword argument types are not widely used.
However, since this is an incompatible change, it would be nice if
implementations check for, and warn about, old-style usage.


Cost of non-adoption:

If nothing is done, the FUNCTION type specifier will continue to be of
limited use for its intended purpose.


Benefits:

Adopting the proposal will clear up an area of confusion in the language
design.


Esthetics:

The syntax is fairly obvious and is analogous to the (<keyword> <variable>)
lambda list syntax.


Discussion:


-------