SBCL supports a metaobject protocol which is intended to be compatible with AMOP; present exceptions to this (as distinct from current bugs) are:
compute-effective-methodonly returns one value, not two.
There is no record of what the second return value was meant to indicate, and apparently no clients for it.
(function standard-object), not
This is to ensure that the
standard-object class is the last of
the standardized classes before
t appearing in the class
precedence list of
standard-generic-function, as required by section 22.214.171.124 of the
ensure-generic-functionare both accepted, with the leftmost argument defining the declarations to be stored and returned by
Where AMOP specifies
:declarations as the keyword argument to
ensure-generic-function, the Common Lisp standard specifies
:declare. Portable code should use
funcallable-standard-classas compatible metaclasses, we impose an additional requirement at class finalization time: a class of metaclass
functionin its superclasses, and a class of metaclass
After a class has been finalized, it is associated with a class
prototype which is accessible by a standard mop function
sb-mop:class-prototype. The user can then ask whether this
object is a
function or not in several different ways: whether it
is a function according to
typep; whether its
function, or whether
function appears in
the superclasses of the class. The additional consistency requirement
comes from the desire to make all of these answers the same.
The following class definitions are bad, and will lead to errors either immediately or if an instance is created:
(defclass bad-object (funcallable-standard-object) () (:metaclass standard-class))
(defclass bad-funcallable-object (standard-object) () (:metaclass funcallable-standard-class))
The following definition is acceptable:
(defclass mixin () ((slot :initarg slot))) (defclass funcallable-object (funcallable-standard-object mixin) () (:metaclass funcallable-standard-class))
and leads to a class whose instances are funcallable and have one slot.
common-lisp-userpackage or exported by any package defined in the ANSI Common Lisp standard.” is interpreted to mean that the standardized classes themselves should not have slots named by external symbols of public packages.
The rationale behind the restriction is likely to be similar to the ANSI Common Lisp restriction on defining functions, variables and types named by symbols in the Common Lisp package: preventing two independent pieces of software from colliding with each other.
(setf sb-mop:slot-value-using-class)are not allowed: all user-defined methods must have a specializer of the class
This prohibition is motivated by a separation of layers: the
slot-value-using-class family of functions is intended for use in
implementing different and new slot allocation strategies, rather than
in performing application-level dispatching. Additionally, with this
requirement, there is a one-to-one mapping between metaclass, class and
slot-definition-class tuples and effective methods of
slot-value-using-class), which permits optimization of
slot-value-using-class)'s discriminating function in the same manner as
Note that application code may specialize on the
argument of slot accessors.
ensure-class, if any, is only redefined if it is the proper name of that class; otherwise, a new class is created.
This is consistent with the description of
ensure-class in AMOP
as the functional version of
defclass, which has this behaviour;
however, it is not consistent with the weaker requirement in AMOP, which
states that any class found by
find-class, no matter what its
class-name, is redefined.
In addition, SBCL supports extensions to the Metaobject protocol from AMOP; at present, they are:
defmethodforms is provided by the
make-method-specializers-formfunction, which returns a form which, when evaluated in the lexical environment of the
defmethod, returns a list of specializer metaobjects. This operator suffers from similar restrictions to those affecting
make-method-lambda, namely that the generic function must be defined when the
defmethodform is expanded, so that the correct method of
make-method-specializers-formis invoked. The system-provided method on
make-method-specializers-formgenerates a call to
find-classfor each symbol specializer name, and a call to
find-method, is provided by
unparse-specializer-using-class, which dispatch on their first argument, the generic function associated with a method with the given specializer. The system-provided methods on those methods convert between classes and proper names and between lists of the form
)and interned eql specializer objects.