The following code triggers an incorrect error:
(use-package :clos)
(defclass my-generic-function (standard-generic-function)
()
(:metaclass funcallable-standard-class)
(:default-initargs
:method-combination (find-method-combination
(class-prototype (find-class 'my-generic-function))
'+ '())))
(defgeneric test (x)
(:generic-function-class my-generic-function))
(defmethod test + (x) 0)
The error message is this:
*** - STANDARD method combination, used by #<MY-GENERIC-
FUNCTION TEST>, allows
no method qualifiers except (:BEFORE :AFTER :AROUND):
#<STANDARD-METHOD + (#<BUILT-IN-CLASS T>)>
However, it should have accepted that method because the method
combination is specified to be '+.
Logged In: YES
user_id=5923
It's not a bug. See the MOP spec p. 19 / 20, description
of DEFGENERIC.
While for
:argument-precedence-order
:documentation
:generic-function-class
:method-class
:declare
the spec says that if the DEFGENERIC form doesn't contain
a specification for this attribute, this keyword does not occur
in the argument list for ENSURE-GENERIC-FUNCTION, for
:method-combination it just says
"The handling of the :method-combination option is
not specified."
Which means, the :method-combination may always be
provided by the DEFGENERIC macro, or never, or
sometimes.
So, trying to specify the method-combination through
:default-initargs is not portable.
But since there is no other apparent way to specify a
default method-combination for a generic-function class
- adding a method to ENSURE-GENERIC-FUNCTION or
to FIND-METHOD-COMBINATION will not help -
I implement this as a new feature in clisp.