[Openmcl-devel] MOP question

Robert Sayre mint at franklinmint.fm
Sat Nov 29 18:45:15 PST 2003


I have some questions about the MOP in OpenMCL .14 and also about a compiler
warning. The following example is taken from an old comp.lang.lisp thread
titled "MOP/pcl anomaly in CMUCL?"*


Welcome to OpenMCL Version (Alpha: Darwin) 0.14-031108!
? (defclass dynamic-slots-class (standard-class) ())
#<STANDARD-CLASS DYNAMIC-SLOTS-CLASS>
?  (defclass test () ((a1)) (:metaclass dynamic-slots-class))
> Error in process listener(1): The class #<STANDARD-CLASS STANDARD-OBJECT> was
> specified as a
> super-class of the class #<DYNAMIC-SLOTS-CLASS TEST>;
> but the meta-classes #<STANDARD-CLASS STANDARD-CLASS> and
> #<STANDARD-CLASS DYNAMIC-SLOTS-CLASS> are incompatible.
> While executing: #<CCL::STANDARD-KERNEL-METHOD SHARED-INITIALIZE :AFTER
(CCL::SLOTS-CLASS T)>
> Type :POP to abort.


>From the usenet thread, I learned that

"It's neccessary to define methods on pcl:validate-superclass more often
than is mentioned in AMOP.

[This] issue will probably lie at the heart of your problem:  Since
test (whose metaclass is dynamic-slots-class) inherits from t (whose
metaclass is standard-class), you have to define this combination
valid"

So, I followed this advice and it worked:


? (defmethod openmcl-mop:validate-superclass
    ((class dynamic-slots-class) (super ccl::standard-class))
  t)
#<STANDARD-METHOD VALIDATE-SUPERCLASS (DYNAMIC-SLOTS-CLASS STANDARD-CLASS)>
? (defclass test () ((a1)) (:metaclass dynamic-slots-class))
#<DYNAMIC-SLOTS-CLASS TEST>


This problem arose while trying to build Common Music for OpenMCL .14.
Common Music runs on a number of implementations, including OpenMCL .13.7
and MCL. It appears that neither of them require the combination to be
declared valid. Is this divergence intentional?

Also, CM uses a function called "finalize-class" that varies based on
implementation. I assume it's there for just this sort of situation. When I
define it the following way, I get a compiler warning, but it seems to work.
If I uncomment the print statement, there is no warning. In the following
example, why doesn't the use of "the-class" in defmethod count as a use of
the variable?

? (defun finalize-class (the-class)
  (progn
    ;(print the-class)
    (defmethod openmcl-mop:validate-superclass
        ((the-class class) (super ccl::standard-class))
            t)))
;Compiler warnings :
;   Unused lexical variable THE-CLASS, in FINALIZE-CLASS.
FINALIZE-CLASS
? (defclass dynamic-slots-class (standard-class) ())
#<STANDARD-CLASS DYNAMIC-SLOTS-CLASS>
? (finalize-class 'dynamic-slots-class)
#<STANDARD-METHOD VALIDATE-SUPERCLASS (CLASS STANDARD-CLASS)>
? (defclass test () ((a1)) (:metaclass dynamic-slots-class))
#<DYNAMIC-SLOTS-CLASS TEST>



Thanks for any help and OpenMCL in general.

Robert Sayre



*Google Groups URL:
http://groups.google.com/groups?threadm=ofiu294qgr.fsf%40chl.tbit.dk



More information about the Openmcl-devel mailing list