All Manuals > LispWorks User Guide and Reference Manual > 18 The Metaobject Protocol

NextPrevUpTopContentsIndex

18.3 Common problems when using the MOP

18.3.1 Inheritance across metaclasses

Usually an inherited class is of the same metaclass as the parent class.

For other kinds of inheritance, you need to define a method on validate-superclass which returns true when called with the respective metaclasses. For example:

(defclass mclass-1 (standard-class)
  ())
 
(defclass mclass-2 (standard-class)
  ())
 
(defclass a ()
  ()
  (:metaclass mclass-1))
 
(defmethod validate-superclass 
           ((class mclass-2) 
            (superclass mclass-1)) 
  t)
 
(defclass b (a)
  ()
  (:metaclass mclass-2))

Without the validate-superclass method, the last form signals an error because mclass-1 is an invalid superclass of mclass-2.

18.3.2 Accessors not using structure instance protocol

By default, defclass creates optimized standard accessors which do not call slot-value-using-class.

This optimization is controlled by the defclass option :optimize-slot-access, which defaults to t.

There is an illustration of this effect of :optimize-slot-access in the example below.

18.3.3 The MOP in delivered images

Issues with MOP code that occur only in delivered LispWorks images are documented in the section "Delivery and the MOP" in the LispWorks Delivery User Guide .


LispWorks User Guide and Reference Manual - 20 Sep 2017

NextPrevUpTopContentsIndex