License: Public Domain , Load it with Quicklisp: (ql:quickload "object-class")
Library type: Convenience features , Project complexity: Trivial/Simple

object-class ensures that special subclasses of standard-object
cluster right in front of standard-object in the class precedence list.

Overview

Using a special subclass of standard-object in instances of a metaclass is a well-known MOP design pattern, as is automatically inserting the needed class in the direct superclasses (since the class precedence list cannot simply add classes that were not declared as direct superclasses).

But design patterns are for when you have run out of language, and we didn't run out of language because this is Common Lisp we're talking about, hence this library.

Dictionary

Dictionary » object-class

Package object-class

Description

All symbols from this package should normally be explicitly qualified, such as object-class:class.
Don't (:use)!

Dictionary » class

Method c2mop:compute-class-precedence-list

(class object-class:class) => precedence-list

Description

Calls object-class:push-back-to-target with the following arguments:

  1. The result of calling the next method;
  2. A function that returns true if its sole argument is an instance of object-class:object-class;
  3. A function that returns true if its sole argument is the class standard-object or funcallable-standard-object;
  4. A function of 2 arguments to-push-back and rest that returns (nreconc to-push-back rest) if rest is true, else signals an error reporting that neither standard-object nor funcallable-standard-object were found in the class precedence list.

Dictionary » push-back-to-target

Function object-class:push-back-to-target

list pushbackp-function targetp-function &optional target-callback => result

Arguments and Values

Description

Let to-push-back be the empty list.

First, traverse list up to the first element for which targetp-function returns true, or to the end of the list if there is no such element.
During this traversal, if pushbackp-function is true of the element, then push it into to-push-back (in reverse order) and remove it from list, else copy it. This processing ends right before the target if it is present.

Second, concatenate the copied results from the first step to the result of calling target-callback with to-push-back and the rest of the list, which has the target as its first element if the target was present in the list.

Dictionary » autosuperclass

Generic Function compatible-metaclasses:autosuperclass

class => classes

Arguments and Values

  • class -- A class.
  • classes -- A list of classes.

Description

Returns the list of classes that should be automatically appended to the end of the list of direct superclasses for this class.

Define a method on this generic function specializing on your metaclass to return the classes you want to append, usually one.

Methods