[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
- To: email@example.com
- Subject: Issue: FUNCTION-TYPE-KEY-NAME
- From: firstname.lastname@example.org (Sandra J Loosemore)
- Date: Tue, 1 Dec 87 12:02:36 MST
References: CLtL p.47-48, 61
Category: CLARIFICATION, CHANGE
Edit history: Version 1, 23-Nov-1987 Sandra Loosemore
Related issues: FUNCTION-TYPE-REST-LIST-ELEMENT
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 keyword arguments may be specified in arbitrary
order in both the the lambda list and the actual argument list. It is not
possible to match up the types specified in the FUNCTION declaration to
either actual arguments or lambda variables without additional information.
(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 symbol in the keyword package.
(2) Allow &ALLOW-OTHER-KEYS to appear in a FUNCTION type specifier lambda
The type of the function SORT could be specified as:
(FUNCTION (SEQUENCE FUNCTION &KEY (:KEY FUNCTION)) SEQUENCE)
(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.
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.
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.
Adopting the proposal will clear up an area of confusion in the language
The syntax is fairly obvious and is analogous to the (<keyword> <variable>)
lambda list syntax.