AMOP and custom metaclasses
Dear list,I would like to understand why the code in AMOP at chapter 3, page 72 does not work for me. I have the feeling it has something to do with what is explained in the LispWorks manual at section 14.2.1 (Inheritance across metaclasses http://www.lispworks.com/documentation/lw60/LW/html/lw-224.htm).
Here is the code in question:
(defclass shape () ())
(defclass rectangle (shape) ())
(defclass counted-class (standard-class)
((:counter :initform 0)))
(setf (find-class 'counted-rectangle)
(make-instance 'counted-class
:name 'counted-rectangle
:direct-superclasses (list (find-class 'rectangle))
:direct-slots ()))
The last form fails with the error:
Error: #<STANDARD-CLASS RECTANGLE 219ECE1B> is an invalid superclass of #<COUNTED-CLASS COUNTED-RECTANGLE 2010504F>.
I tried to implement a specialization of validate-superclass, but that does not help:
(defmethod validate-superclass (class (superclass rectangle))
(eq 'counted-rectangle (class-name class)))
I would appreciate if someone could help me understand this issue.
Have a nice week-end!
Camille