I do not have my copy of AMOP with me, perhaps it is explained
in there. But can anyone see what is wrong with this simple
example? The message says that i should declare a method on
PCL:VALIDATE-SUPERCLASS dispatching on PCL:FUNCALLABLE-STANDARD-CLASS
and STANDARD-CLASS, but that sounds it might have lots of
dangerous side effects!!! (btw, I'm using cmucl 19a).
(defclass super-method ( STANDARD-METHOD)
nil)
(defclass super-generic ( STANDARD-GENERIC-FUNCTION )
nil)
(defgeneric myfun ( x)
(:method-class super-method)
(:generic-function-class super-generic))
The message I get is:
Error in function "DEFMETHOD SHARED-INITIALIZE :AFTER (STD-CLASS T)":
The class #<FUNCALLABLE-STANDARD-CLASS STANDARD-GENERIC-FUNCTION
{281A6685}>
was specified as a super-class of the class
#<STANDARD-CLASS SUPER-GENERIC {58004355}>, but the meta-classes
#<STANDARD-CLASS PCL:FUNCALLABLE-STANDARD-CLASS {281A6725}> and
#<STANDARD-CLASS STANDARD-CLASS {281A4305}> are incompatible. Define a
method for PCL:VALIDATE-SUPERCLASS to avoid this error.
[Condition of type SIMPLE-ERROR]
Jim Newton wrote:
> I do not have my copy of AMOP with me, perhaps it is explained
> in there. But can anyone see what is wrong with this simple
> example? The message says that i should declare a method on
> PCL:VALIDATE-SUPERCLASS dispatching on PCL:FUNCALLABLE-STANDARD-CLASS
> and STANDARD-CLASS, but that sounds it might have lots of
> dangerous side effects!!! (btw, I'm using cmucl 19a).
>
>
> (defclass super-method ( STANDARD-METHOD)
> nil)
>
> (defclass super-generic ( STANDARD-GENERIC-FUNCTION )
> nil)
>
> (defgeneric myfun ( x)
> (:method-class super-method)
> (:generic-function-class super-generic))
>
>
> The message I get is:
>
> Error in function "DEFMETHOD SHARED-INITIALIZE :AFTER (STD-CLASS T)":
> The class #<FUNCALLABLE-STANDARD-CLASS STANDARD-GENERIC-FUNCTION
> {281A6685}>
> was specified as a super-class of the class
> #<STANDARD-CLASS SUPER-GENERIC {58004355}>, but the meta-classes
> #<STANDARD-CLASS PCL:FUNCALLABLE-STANDARD-CLASS {281A6725}> and
> #<STANDARD-CLASS STANDARD-CLASS {281A4305}> are incompatible.
Define a
> method for PCL:VALIDATE-SUPERCLASS to avoid this error.
> [Condition of type SIMPLE-ERROR]
Make this:
(defclass super-generic (standard-generic-function)
()
(:metaclass funcallable-standard-class))
BTW, PCL is very touchy wrt generic functions: According to AMOP,
funcallable-standard-class and standard-class should be compatible by
default, and furthermore you can only subclass
standard-generic-function once. However, the second subclass of s-g-f
gives you a crash in PCL.
Currently, clisp has the most compatible MOP implementation, so it may
be a better idea to prototype your stuff in clisp and then see how to
port it to other CL implementations.
Pascal