Congruence of lamda-lists of methods with their generic-function
jean.claude.beaudoin at gmail.com
Sun Feb 9 04:09:31 UTC 2014
Hello CL Pros,
I am trying to understand the meaning in conforming ANSI CL
of the following code snippet and I am not quite sure what to think of it:
(defgeneric foo (a b &key))
(defmethod foo (a b &key c d) (or c d 42))
At this point should a call to foo accept any keyword
argument, no keyword argument or only :c and/or :d?
What would be the outcome of this:
(foo 1 2 :d 3)
Is it an error being signaled or the value 3 being returned?
I am inclined to believe that an error should be signaled,
since the generic function lambda-list contains no
explicit keyword argument and no &allow-other-keys.
Reading CLHS 7.6.4 it seems to me that
(defgeneric foo (a b &key)) and
(defgeneric foo (a b &key &allow-other-keys))
are two different things as to the set of keyword arguments
they each will accept. The first one being the empty set
and the second the set of all possible sequence of
keyword arguments (limits set aside). Am I right?
Also if I go for (defgeneric (a b &key &allow-other-keys)),
is the lambda-list of the method as here above still congruent?
Doesn't it need to be rewritten as:
(defmethod foo (a b &key c d &allow-other-keys) ...)
(defmethod foo (a b &rest other-args) ...)
to be properly congruent?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the pro