• TOC
  • Prev
  • Up
  • Next

Implementation and User Specialization

The purpose of the Metaobject Protocol is to provide users with a powerful mechanism for extending and customizing the basic behavior of the Common Lisp Object System. As an object-oriented description of the basic CLOS behavior, the Metaobject Protocol makes it possible to create these extensions by defining specialized subclasses of existing metaobject classes.

The Metaobject Protocol provides this capability without interfering with the implementor's ability to develop high-performance implementations. This balance between user extensibility and implementor freedom is mediated by placing explicit restrictions on each. Some of these restrictions are general---they apply to the entire class graph and the applicability of all methods. These are presented in this section.

The following additional terminology is used to present these restrictions:

  • Metaobjects are divided into three categories. Those defined in this document are called specified; those defined by an implementation but not mentioned in this document are called implementation-specific; and those defined by a portable program are called portable.
  • A class I is interposed between two other classes C1 and C2 if and only if there is some path, following direct superclasses, from the class C1 to the class C2 which includes I.
  • A method is specialized for a class if and only if
    • that class is in the list of specializers associated with the method; and
    • the method is in the list of methods associated with some generic function.
  • In a given implementation, a specified method is said to have been promoted if and only if the specializers of the method, S1 ... Sn are defined in this specification as the classes C1 ... Cn, but in the implementation, one or more of the specializers Si, is a superclass of the class given in the specification Ci.
  • For a given generic function and set of arguments, a method M2 extends a method M1 if and only if:
    1. M1 and M2 are both associated with the given generic function,
    2. M1 and M2 are both applicable to the given arguments,
    3. the specializers and qualifiers of the methods are such that when the generic function is called, M2 is executed before M1,
    4. M1 will be executed if and only if call-next-method is invoked from within the body of M2 and
    5. call-next-method is invoked from within the body of M2, thereby causing M1 to be executed.
  • For a given generic function and set of arguments, a method M2 overrides a method M1 if and only if conditions i through iv above hold and
    • call-next-method is not invoked from within the body of M2, thereby preventing M1 from being executed.
  • Restrictions on implementations
  • Restrictions on portable programs