Jim Newton
8/24/2015 9:47:00 AM
I have defined a class named HAS-CALL which has an application specific metaclass named APP-METACLASS.
I would like all subclasses of HAS-CALL to also have the same meta-class, or potentially a subclass thereof.
The only way I can think of doing this is write a macro around defclass, or simply just always remember.
(defclass U (has-call)
()
(:metaclass app-metaclass))
(defclass V (U)
()
(:metaclass app-metaclass))
(defclass W (V)
()
(:metaclass app-metaclass))
If I forget, and define W as follows, I get the error shown below.
(defclass W (V)
())
The class #<APP-METACLASS V> was specified as a superclass of
the class #<STANDARD-CLASS W {101EE831D3}>, but the metaclasses
#<STANDARD-CLASS APP-METACLASS> and
#<STANDARD-CLASS STANDARD-CLASS> are incompatible.
[Condition of type SB-PCL::INVALID-SUPERCLASS]
See also:
The Art of the Metaobject Protocol, VALIDATE-SUPERCLASS [:generic-function]
Isn't there a way enhance either HAS-CALL or APP-METACLASS to enforce this automatically?
I've looked into ensure-class-using-class, but it is not clear to me how to make it work.