<div dir="ltr"><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div>Hello CL Pros,<br><br></div>I am trying to understand the meaning in conforming ANSI CL<br>
of the following code snippet and I am not quite sure what to think of it:<br></div><br></div>(defgeneric foo (a b &key))<br><br></div>(defmethod foo (a b &key c d) (or c d 42))<br><br></div>At this point should a call to foo accept any keyword<br>
</div>argument, no keyword argument or only :c and/or :d?<br></div>What would be the outcome of this:<br><br></div>(foo 1 2 :d 3)<br><br></div>Is it an error being signaled or the value 3 being returned?<br></div>I am inclined to believe that an error should be signaled,<br>
</div><div>since the generic function lambda-list contains no<br></div><div>explicit keyword argument and no &allow-other-keys.<br></div><div><br>Reading CLHS 7.6.4 it seems to me that<br></div>(defgeneric foo (a b &key)) and<br>
</div>(defgeneric foo (a b &key &allow-other-keys))<br></div>are two different things as to the set of keyword arguments<br></div>they each will accept. The first one being the empty set<br></div>and the second the set of all possible sequence of<br>
</div>keyword arguments (limits set aside). Am I right?<br><br></div>Also if I go for (defgeneric (a b &key &allow-other-keys)),<br></div>is the lambda-list of the method as here above still congruent?<br></div>Doesn't it need to be rewritten as:<br>
<br></div>(defmethod foo (a b &key c d &allow-other-keys) ...)<br></div>or<br></div>(defmethod foo (a b &rest other-args) ...)<br><br></div>to be properly congruent?<br><br></div>Thanks,<br><br></div>Jean-Claude Beaudoin<br>
<br></div>