12.2.5 Parameter-list congruence
A generic function and its methods must all have parameter lists that are compatible, or congruent. Following are the basic rules:
A generic function and its methods must all have the same number of required arguments.
The type of any given parameter in each method must be a subtype of the corresponding parameter in the generic function.
If a generic function or any of its methods has only required arguments — that is, it has neither
#restnor#keyin its parameter list — then the generic function and all its methods must have only required arguments.If a generic function or any of its methods accepts a variable number of arguments, but does not accept keyword arguments — that is, it has
#rest, but does not have#key, in its parameter list — then the generic function and all its methods must accept a variable number of arguments, but must not accept keyword arguments.If a generic function or any of its methods accepts keyword arguments — that is, it has
#keyin its parameter list — then the generic function and all its methods must accept keyword arguments. For this rule, a generic function or method "accepts keyword arguments" even if its parameter list ends with just#key.If a generic function has any specific keyword parameters, then all its methods must have (at least) those specific keyword parameters. The appearance of
#all-keysin a method's parameter list does not satisfy this requirement.
The following parameter lists are congruent, because both functions have only required arguments, they have the same number of required arguments, and the type of each method parameter is a subtype of the same parameter in the generic function:
define generic g (arg1 :: <complex>, arg2 :: <integer>); define method g (arg1 :: <real>, arg2 :: <integer>) ... end method g;
The following parameter lists are congruent, because both functions meet the tests for required arguments, both accept keyword arguments, and the generic function has no specific keyword parameters:
define generic g (arg1 :: <real>, #key); define method g (arg1 :: <integer>, #key base :: <integer> = 10) ... end method g;
The following parameter lists are not congruent, because the method's parameter list does not include the specific keyword base of the generic function, even though it does include #all-keys:
define generic g (arg1 :: <integer>, #key base); define method g (arg1 :: <integer>, #key #all-keys) ... end method g;




