License: Public Domain , Load it with Quicklisp: (ql:quickload "compatible-metaclasses")
Library type: Convenience , Project complexity: Simple

compatible-metaclasses validates superclasses according to a simple substitution model,
thereby greatly simplifying the definition of class mixins.


Traditionally, defining "class mixins" (subclasses of metaclasses, for instance if you just want to add a slot and/or a few methods) has been surprisingly hard due to the combinatorial explosion of c2mop:validate-superclass methods needed when using the naive approach. This library defines a simple substitution model that completely solves this problem.

Here is an example usage:

(defclass my-class-mixin (compatible-metaclasses:standard-class metaclass)
  (:metaclass compatible-metaclasses:standard-metaclass)
  (:validate-as metaclass))

Note that compatible-metaclasses:standard-metaclass, being used as the metaclass of a metaclass, is thus a metametaclass!

Also note that compatible-metaclasses:standard-class will be effectively ignored in any subclasses of my-class-mixin that don't have compatible-metaclasses:standard-metaclass as their metaclass, which is exactly what we want since we can't safely make any assumptions about how c2mop:validate-superclass should behave (i.e. metaclass compatibility) for those subclasses.


Dictionary » compatible-metaclasses

Dictionary » Core

Dictionary » Core » class

Class compatible-metaclasses:class



Metaclasses inheriting from this class will potentially substitute the class and/or the superclass for another class during c2mop:validate-superclass.

Dictionary » Core » substitute

Generic Function compatible-metaclasses:substitute

class => substitute

Arguments and Values

  • class -- A class.
  • substitute -- A class.


Returns the substitute to use instead of the original class for purposes of superclass validation by c2mop:validate-superclass. Returns class if no substitution is desired.


Dictionary » Standard

Dictionary » Standard » standard-class

Dictionary » Standard » standard-metaclass

Dictionary » Standard » validate-as-mixin

Dictionary » Standard » validate-as

Generic Function compatible-metaclasses:validate-as

metametaclass => metaclass


Returns the metaclass to use instead of the instance of this metametaclass to check compatibility using c2mop:validate-superclass.

Dictionary » Standard » metasubstitute-mixin

Dictionary » Standard » metasubstitute

Generic Function compatible-metaclasses:metasubstitute

metametaclass => metasubstitute

Arguments and Values

  • metametaclass -- A class.
  • substitute -- A class or nil.


Returns the substitute that instances of this metametaclass which inherit from compatible-metaclasses:standard-class should use to check compatibility using c2mop:validate-superclass, or nil if the original class should be used.


Method compatible-metaclasses:metasubstitute

(metametaclass class) => metasubstitute


Returns nil.