|
Allegro CL |
This chapter describes each of the functions and generic functions that make up the CLOS Metaobject Protocol. The descriptions appear in alphabetical order with the exception that all the reader generic functions for each kind of metaobject are grouped together. So, for example, method-function would be found with method-qualifiers and other method metaobject readers under ``Readers for Method Metaobjects.''
The description of functions follows the same form as used in the CLOS specification. The description of generic functions is similar to that in the CLOS specification, but some minor changes have been made in the way methods are presented.
The following is an example of the format for the syntax description of a generic function:
gf1 x y &optional z &key k
This description indicates that gf1 is a generic function with two required parameters, x and y, an optional parameter z and a keyword parameter k.
The description of a generic function includes a description of its behavior. This provides the general behavior, or protocol of the generic function. All methods defined on the generic function, both portable and specified, must have behavior consistent with this description.
Every generic function described in this section is an instance of the class standard-generic-function and uses standard method combination.
The description of a generic function also includes descriptions of the specified methods for that generic function. In the description of these methods, a method signature is used to describe the parameters and parameter specializers of each method. The following is an example of the format for a method signature:
Primary Method gf1 (x class) y &optional z &key k
This signature indicates that this primary method on the generic function gf1 has two required parameters, named x and y. In addition, there is an optional parameter z and a keyword parameter k. This signature also indicates that the method's parameter specializers are the classes named class and t.
The description of each method includes a description of the behavior particular to that method.
An abbreviated syntax is used when referring to a method defined elsewhere in the document. This abbreviated syntax includes the name of the generic function, the qualifiers, and the parameter specializers. A reference to the method with the signature shown above is written as: gf1 (class t).
Generic Function
add-dependentSyntax:
add-dependent metaobject dependent
Arguments:
The metaobject argument is a class or generic function metaobject.
The dependent argument is an object.
Values:
The value returned by this generic function is unspecified.
Purpose:
This generic function adds dependent to the dependents of metaobject. If dependent is already in the set of dependents it is not added again (no error is signaled).
The generic function map-dependents can be called to access the set of dependents of a class or generic function. The generic function remove-dependent can be called to remove an object from the set of dependents of a class or generic function. The effect of calling add-dependent or remove-dependent while a call to map-dependents on the same class or generic function is in progress is unspecified.
The situations in which add-dependent is called are not specified.
Methods:
Primary Method add-dependent (class standard-class) dependent
No behavior is specified for this method beyond that which is specified for the generic function.
This method cannot be overridden unless the following methods are overridden as well:
remove-dependent (standard-class t)
map-dependents (standard-class t)
Primary Method add-dependent (class funcallable-standard-class) dependent
No behavior is specified for this method beyond that which is specified for the generic function.
This method cannot be overridden unless the following methods are overridden as well:
remove-dependent (funcallable-standard-class t)
map-dependents (funcallable-standard-class t)
Primary Method add-dependent (generic-function standard-generic-function) dependent
No behavior is specified for this method beyond that which is specified for the generic function.
This method cannot be overridden unless the following methods are overridden as well:
remove-dependent (standard-generic-function t)
map-dependents (standard-generic-function t)
Notes:
See the ``Dependent Maintenance Protocol'' section for remarks about the use of this facility.
Generic Function
add-direct-methodSyntax:
add-direct-method specializer method
Arguments:
The specializer argument is a specializer metaobject.
The method argument is a method metaobject.
Values:
The value returned by this generic function is unspecified.
Purpose:
This generic function is called to maintain a set of backpointers from a specializer to the set of methods specialized to it. If method is already in the set, it is not added again (no error is signaled).
This set can be accessed as a list by calling the generic function specializer-direct-methods. Methods are removed from the set by remove-direct-method.
The generic function add-direct-method is called by add-method whenever a method is added to a generic function. It is called once for each of the specializers of the method. Note that in cases where a specializer appears more than once in the specializers of a method, this generic function will be called more than once with the same specializer as argument.
The results are undefined if the specializer argument is not one of the specializers of the method argument.
Methods:
Primary Method add-direct-method (specializer class) (method method)
This method implements the behavior of the generic function for class specializers. No behavior is specified for this method beyond that which is specified for the generic function.
This method cannot be overridden unless the following methods are overridden as well:
remove-direct-method (class method)
specializer-direct-generic-functions (class)
specializer-direct-methods (class)
Primary Method add-direct-method (specializer eql-specializer) (method method)
This method implements the behavior of the generic function for eql specializers. No behavior is specified for this method beyond that which is specified for the generic function.
Generic Function add-direct-subclass
Syntax:
add-direct-subclass superclass subclass
Arguments:
The superclass argument is a class metaobject.
The subclass argument is a class metaobject.
Values:
The value returned by this generic function is unspecified.
Purpose:
This generic function is called to maintain a set of backpointers from a class to its direct subclasses. This generic function adds subclass to the set of direct subclasses of superclass.
When a class is initialized, this generic function is called once for each direct superclass of the class.
When a class is reinitialized, this generic function is called once for each added direct superclass of the class. The generic function remove-direct-subclass is called once for each deleted direct superclass of the class.
Methods:
Primary Method add-direct-subclass (superclass class) (subclass class)
No behavior is specified for this method beyond that which is specified for the generic function.
This method cannot be overridden unless the following methods are overridden as well:
remove-direct-subclass (class class)
class-direct-subclasses (class)
Generic Function add-method
Syntax:
add-method generic-function method
Arguments:
The generic-function argument is a generic function metaobject.
The method argument is a method metaobject.
Values:
The generic-function argument is returned.
Purpose:
This generic function associates an unattached method with a generic function.
An error is signaled if the lambda list of the method is not congruent with the lambda list of the generic function. An error is also signaled if the method is already associated with some other generic function.
If the given method agrees with an existing method of the generic function on parameter specializers and qualifiers, the existing method is removed by calling remove-method before the new method is added. See the section of the CLOS Specification called ``Agreement on Parameter Specializers and Qualifiers'' for a definition of agreement in this context.
Associating the method with the generic function then proceeds in four steps: (i) add method to the set returned by generic-function-methods and arrange for method-generic-function to return generic-function; (ii) call add-direct-method for each of the method's specializers; (iii) call compute-discriminating-function and install its result with set-funcallable-instance-function; and (iv) update the dependents of the generic function.
The generic function add-method can be called by the user or the implementation.
Methods:
Primary Method add-method (generic-function standard-generic-function) (method standard-method)
No behavior is specified for this method beyond that which is specified for the generic function.
Generic Function
allocate-instanceSyntax:
allocate-instance class &rest initargs
Arguments:
The class argument is a class metaobject.
The initargs argument consists of alternating initialization argument names and values.
Values:
The value returned is a newly allocated instance of class.
Purpose:
This generic function is called to create a new, uninitialized instance of a class. The interpretation of the concept of an ``uninitialized'' instance depends on the class metaobject class.
Before allocating the new instance, class-finalized-p is called to see if class has been finalized. If it has not been finalized, finalize-inheritance is called before the new instance is allocated.
Methods:
Primary Method allocate-instance (class standard-class) &rest initargs
This method allocates storage in the instance for each slot with allocation :instance. These slots are unbound. Slots with any other allocation are ignored by this method (no error is signaled).
Primary Method allocate-instance (class funcallable-standard-class) &rest initargs
This method allocates storage in the instance for each slot with allocation :instance. These slots are unbound. Slots with any other allocation are ignored by this method (no error is signaled).
The funcallable instance function of the instance is undefined---the results are undefined if the instance is applied to arguments before set-funcallable-instance-function has been used to set the funcallable instance function.
Primary Method allocate-instance (class built-in-class) &rest initargs
This method signals an error.
Generic Function class-...
The following generic functions are described together under ``Readers for Class Metaobjects'': class-default-initargs, class-direct-default-initargs, class-direct-slots, class-direct-subclasses, class-direct-superclasses, class-finalized-p, class-name, class-precedence-list, class-prototype and class-slots.
Generic Function
compute-applicable-methodsSyntax:
compute-applicable-methods generic-function arguments
Arguments:
The generic-function argument is a generic function metaobject.
The arguments argument is a list of objects.
Values:
This generic function returns a possibly empty list of method metaobjects.
Purpose:
This generic function determines the method applicability of a generic function given a list of required arguments. The returned list of method metaobjects is sorted by precedence order with the most specific method appearing first. If no methods are applicable to the supplied arguments the empty list is returned.
When a generic function is invoked, the discriminating function must determine the ordered list of methods applicable to the arguments. Depending on the generic function and the arguments, this is done in one of three ways: using a memoized value; calling compute-applicable-methods-using-classes; or calling compute-applicable-methods. (Refer to the description of compute-discriminating-function for the details of this process.)
The arguments argument is permitted to contain more elements than the generic function accepts required arguments; in these cases the extra arguments will be ignored. An error is signaled if arguments contains fewer elements than the generic function accepts required arguments.
The list returned by this generic function will not be mutated by the implementation. The results are undefined if a portable program mutates the list returned by this generic function.
Methods:
Primary Method compute-applicable-methods (generic-function standard-generic-function) arguments
This method signals an error if any method of the generic function has a specializer which is neither a class metaobject nor an eql specializer metaobject.
Otherwise, this method computes the sorted list of applicable methods according to the rules described in the section of the CLOS Specification called ``Method Selection and Combination.''
This method can be overridden. Because of the consistency requirements between this generic function and compute-applicable-methods-using-classes, doing so may require also overriding compute-applicable-methods-using-classes (standard-generic-function t).
Generic Function
compute-applicable-methods-using-classesSyntax:
compute-applicable-methods-using-classes generic-function classes
Arguments:
The generic-function argument is a generic function metaobject.
The classes argument is a list of class metaobjects.
Values:
This generic function returns two values. The first is a possibly empty list of method metaobjects. The second is either true or false.
Purpose:
This generic function is called to attempt to determine the method applicability of a generic function given only the classes of the required arguments.
If it is possible to completely determine the ordered list of applicable methods based only on the supplied classes, this generic function returns that list as its first value and true as its second value. The returned list of method metaobjects is sorted by precedence order, the most specific method coming first. If no methods are applicable to arguments with the specified classes, the empty list and true are returned.
If it is not possible to completely determine the ordered list of applicable methods based only on the supplied classes, this generic function returns an unspecified first value and false as its second value.
When a generic function is invoked, the discriminating function must determine the ordered list of methods applicable to the arguments. Depending on the generic function and the arguments, this is done in one of three ways: using a memoized value; calling compute-applicable-methods-using-classes; or calling compute-applicable-methods. (Refer to the description of compute-discriminating-function for the details of this process.)
The following consistency relationship between compute-applicable-methods-using-classes and compute-applicable-methods must be maintained: for any given generic function and set of arguments, if compute-applicable-methods-using-classes returns a second value of true, the first value must be equal to the value that would be returned by a corresponding call to compute-applicable-methods. The results are undefined if a portable method on either of these generic functions causes this consistency to be violated.
The list returned by this generic function will not be mutated by the implementation. The results are undefined if a portable program mutates the list returned by this generic function.
Methods:
Primary Method compute-applicable-methods-using-classes (generic-function standard-generic-function) classes
If any method of the generic function has a specializer which is neither a class metaobject nor an eql specializer metaobject, this method signals an error.
In cases where the generic function has no methods with eql specializers, or has no methods with eql specializers that could be applicable to arguments of the supplied classes, this method returns the ordered list of applicable methods as its first value and true as its second value.
Otherwise this method returns an unspecified first value and false as its second value.
This method can be overridden. Because of the consistency requirements between this generic function and compute-applicable-methods, doing so may require also overriding compute-applicable-methods (standard-generic-function t).
Notes:
This generic function exists to allow user extensions which alter method lookup rules, but which base the new rules only on the classes of the required arguments, to take advantage of the class-based method lookup memoization found in many implementations. (There is of course no requirement for an implementation to provide this optimization.)
Such an extension can be implemented by two methods, one on this generic function and one on compute-applicable-methods. Whenever the user extension is in effect, the first method will return a second value of true. This should allow the implementation to absorb these cases into its own memoization scheme.
To get appropriate performance, other kinds of extensions may require methods on compute-discriminating-function which implement their own memoization scheme.
Generic Function
compute-class-precedence-listSyntax:
compute-class-precedence-list class
Arguments:
The class argument is a class metaobject.
Values:
The value returned by this generic function is a list of class metaobjects.
Purpose:
This generic-function is called to determine the class precedence list of a class.
The result is a list which contains each of class and its superclasses once and only once. The first element of the list is class and the last element is the class named t.
All methods on this generic function must compute the class precedence list as a function of the ordered direct superclasses of the superclasses of class. The results are undefined if the rules used to compute the class precedence list depend on any other factors.
When a class is finalized, finalize-inheritance calls this generic function and associates the returned value with the class metaobject. The value can then be accessed by calling class-precedence-list.
The list returned by this generic function will not be mutated by the implementation. The results are undefined if a portable program mutates the list returned by this generic function.
Methods:
Primary Method compute-class-precedence-list (class class)
This method computes the class precedence list according to the rules described in the section of the CLOS Specification called ``Determining the Class Precedence List.''
This method signals an error if class or any of its superclasses is a forward referenced class.
This method can be overridden.
Generic Function
compute-default-initargsSyntax:
compute-default-initargs class
Arguments:
The class argument is a class metaobject.
Values:
The value returned by this generic function is a list of canonicalized default initialization arguments.
Purpose:
This generic-function is called to determine the default initialization arguments for a class.
The result is a list of canonicalized default initialization arguments, with no duplication among initialization argument names.
All methods on this generic function must compute the default initialization arguments as a function of only: (i) the class precedence list of class, and (ii) the direct default initialization arguments of each class in that list. The results are undefined if the rules used to compute the default initialization arguments depend on any other factors.
When a class is finalized, finalize-inheritance calls this generic function and associates the returned value with the class metaobject. The value can then be accessed by calling class-default-initargs.
The list returned by this generic function will not be mutated by the implementation. The results are undefined if a portable program mutates the list returned by this generic function.
Methods:
Primary Method compute-default-initargs
(class standard-class)
Primary Method compute-default-initargs
(class funcallable-standard-class)
These methods compute the default initialization arguments according to the rules described in the section of the CLOS Specification called ``Defaulting of Initialization Arguments.''
These methods signal an error if class or any of its superclasses is a forward referenced class.
These methods can be overridden.
Generic Function compute-discriminating-function
Syntax:
compute-discriminating-function generic-function
Arguments:
The generic-function argument is a generic function metaobject.
Values:
The value returned by this generic function is a function.
Purpose:
This generic function is called to determine the discriminating function for a generic function. When a generic function is called, the installed discriminating function is called with the full set of arguments received by the generic function, and must implement the behavior of calling the generic function: determining the ordered set of applicable methods, determining the effective method, and running the effective method.
To determine the ordered set of applicable methods, the discriminating function first calls compute-applicable-methods-using-classes. If compute-applicable-methods-using-classes returns a second value of false, the discriminating function then calls compute-applicable-methods.
When compute-applicable-methods-using-classes returns a second value of true, the discriminating function is permitted to memoize the first returned value as follows. The discriminating function may reuse the list of applicable methods without calling compute-applicable-methods-using-classes again provided that:
Determination of the effective method is done by calling compute-effective-method. When the effective method is run, each method's function is called, and receives as arguments: (i) a list of the arguments to the generic function, and (ii) whatever other arguments are specified in the call-method form indicating that the method should be called. (See make-method-lambda for more information about how method functions are called.)
The generic function compute-discriminating-function is called, and its result installed, by add-method, remove-method, initialize-instance and reinitialize-instance.
Methods:
Primary Method compute-discriminating-function (generic-function standard-generic-function)
No behavior is specified for this method beyond that specified for the generic function.
This method can be overridden.
Generic Function compute-effective-method
Syntax:
compute-effective-method generic-function method-combination methods
Arguments:
The generic-function argument is a generic function metaobject.
The method-combination argument is a method combination metaobject.
The methods argument is a list of method metaobjects.
Values:
This generic function returns two values. The first is an effective method, the second is a list of effective method options.
Purpose:
This generic function is called to determine the effective method from a sorted list of method metaobjects.
An effective method is a form that describes how the applicable methods are to be combined. Inside of effective method forms are call-method forms which indicate that a particular method is to be called. The arguments to the call-method form indicate exactly how the method function of the method should be called. (See make-method-lambda for more details about method functions.)
An effective method option has the same interpretation and syntax as either the :arguments or the :generic-function option in the long form of define-method-combination.
More information about the form and interpretation of effective methods and effective method options can be found under the description of the define-method-combination macro in the CLOS specification.
This generic function can be called by the user or the implementation. It is called by discriminating functions whenever a sorted list of applicable methods must be converted to an effective method.
Methods:
Primary Method compute-effective-method (generic-function standard-generic-function) method-combination methods
This method computes the effective method according to the rules of the method combination type implemented by method-combination.
This method can be overridden.
Generic Function compute-effective-slot-definition
Syntax:
compute-effective-slot-definition class name direct-slot-definitions
Arguments:
The class argument is a class metaobject.
The name argument is a slot name.
The direct-slot-definitions argument is an ordered list of direct slot definition metaobjects. The most specific direct slot definition metaobject appears first in the list.
Values:
The value returned by this generic function is an effective slot definition metaobject.
Purpose:
This generic function determines the effective slot definition for a slot in a class. It is called by compute-slots once for each slot accessible in instances of class.
This generic function uses the supplied list of direct slot definition metaobjects to compute the inheritance of slot properties for a single slot. The returned effective slot definition represents the result of computing the inheritance. The name of the new effective slot definition is the same as the name of the direct slot definitions supplied.
The class of the effective slot definition metaobject is determined by calling effective-slot-definition-class. The effective slot definition is then created by calling make-instance. The initialization arguments passed in this call to make-instance are used to initialize the new effective slot definition metaobject. See ``Initialization of Slot Definition Metaobjects'' for details.
Methods:
Primary Method compute-effective-slot-definition (class standard-class) name direct-slot-definitions
This method implements the inheritance and defaulting of slot options following the rules described in the ``Inheritance of Slots and Options'' section of the CLOS Specification.
This method can be extended, but the value returned by the extending method must be the value returned by this method.
Primary Method compute-effective-slot-definition (class funcallable-standard-class) name direct-slot-definitions
This method implements the inheritance and defaulting of slot options following the rules described in the ``Inheritance of Slots and Options'' section of the CLOS Specification.
This method can be extended, but the value returned by the extending method must be the value returned by this method.
Generic Function compute-slots
Syntax:
compute-slots class
Arguments:
The class argument is a class metaobject.
Values:
The value returned is a set of effective slot definition metaobjects.
Purpose:
This generic function computes a set of effective slot definition metaobjects for the class class. The result is a list of effective slot definition metaobjects: one for each slot that will be accessible in instances of class.
This generic function proceeds in 3 steps:
The first step collects the full set of direct slot definitions from the superclasses of class.
The direct slot definitions are then collected into individual lists, one list for each slot name associated with any of the direct slot definitions. The slot names are compared with eql. Each such list is then sorted into class precedence list order. Direct slot definitions coming from classes earlier in the class precedence list of class appear before those coming from classes later in the class precedence list. For each slot name, the generic function compute-effective-slot-definition is called to compute an effective slot definition. The result of compute-slots is a list of these effective slot definitions, in unspecified order.
In the final step, the location for each effective slot definition is set. This is done by specified around-methods; portable methods cannot take over this behavior. For more information on the slot definition locations, see the section ``Instance Structure Protocol.''
The list returned by this generic function will not be mutated by the implementation. The results are undefined if a portable program mutates the list returned by this generic function.
Methods:
Primary Method compute-slots (class standard-class)
This method implements the specified behavior of the generic function.
This method can be overridden.
Primary Method compute-slots (class funcallable-standard-class)
This method implements the specified behavior of the generic function.
This method can be overridden.
Around Method compute-slots (class standard-class)
This method implements the specified behavior of computing and storing slot locations. This method cannot be overridden.
Around Method compute-slots (class funcallable-standard-class)
This method implements the specified behavior of computing and storing slot locations. This method cannot be overridden.
Generic Function direct-slot-definition-class
Syntax:
direct-slot-definition-class class &rest initargs
Arguments:
The class argument is a class metaobject.
The initargs argument is a set of initialization arguments and values.
Values:
The value returned is a subclass of the class direct-slot-definition.
Purpose:
When a class is initialized, each of the canonicalized slot specifications must be converted to a direct slot definition metaobject. This generic function is called to determine the class of that direct slot definition metaobject.
The initargs argument is simply the canonicalized slot specification for the slot.
Methods:
Primary Method direct-slot-definition-class (class standard-class) &rest initargs
This method returns the class standard-direct-slot-definition.
This method can be overridden.
Primary Method direct-slot-definition-class (class funcallable-standard-class) &rest initargs
This method returns the class standard-direct-slot-definition.
This method can be overridden.
Generic Function effective-slot-definition-class
Syntax:
effective-slot-definition-class class &rest initargs
Arguments:
The class argument is a class metaobject.
The initargs argument is a set of initialization arguments and values.
Values:
The value returned is a subclass of the class effective-slot-definition.
Purpose:
This generic function is called by compute-effective-slot-definition to determine the class of the resulting effective slot definition metaobject. The initargs argument is the set of initialization arguments and values that will be passed to make-instance when the effective slot definition metaobject is created.
Methods:
Primary Method effective-slot-definition-class (class standard-class) &rest initargs
This method returns the class standard-effective-slot-definition.
This method can be overridden.
Primary Method effective-slot-definition-class (class funcallable-standard-class) &rest initargs
This method returns the class standard-effective-slot-definition.
This method can be overridden.
Function ensure-class
Syntax:
ensure-class name &key &allow-other-keys
Arguments:
The name argument is a symbol.
Some of the keyword arguments accepted by this function are actually processed by ensure-class-using-class, others are processed during initialization of the class metaobject (as described in the section called ``Initialization of Class Metaobjects'').
Values:
The result is a class metaobject.
Purpose:
This function is called to define or redefine a class with the specified name, and can be called by the user or the implementation. It is the functional equivalent of defclass, and is called by the expansion of the defclass macro.
The behavior of this function is actually implemented by the generic function ensure-class-using-class. When ensure-class is called, it immediately calls ensure-class-using-class and returns that result as its own.
The first argument to ensure-class-using-class is computed as follows:
The second argument is name. The remaining arguments are the complete set of keyword arguments received by the ensure-class function.
Generic Function ensure-class-using-class
Syntax:
ensure-class-using-class class name &key direct-default-initargs direct-slots direct-superclasses name metaclass &allow-other-keys
Arguments:
The class argument is a class metaobject or nil.
The name argument is a class name.
The :metaclass argument is a class metaobject class or a class metaobject class name. If this argument is not supplied, it defaults to the class named standard-class. If a class name is supplied, it is interpreted as the class with that name. If a class name is supplied, but there is no such class, an error is signaled.
The :direct-superclasses argument is a list of which each element is a class metaobject or a class name. An error is signaled if this argument is not a proper list.
For the interpretation of additional keyword arguments, see ``Initialization of Class Metaobjects''.
Values:
The result is a class metaobject.
Purpose:
This generic function is called to define or modify the definition of a named class. It is called by the ensure-class function. It can also be called directly.
The first step performed by this generic function is to compute the set of initialization arguments which will be used to create or reinitialize the named class. The initialization arguments are computed from the full set of keyword arguments received by this generic function as follows:
If the class argument is nil, a new class metaobject is created by calling the make-instance generic function with the value of the :metaclass argument as its first argument, and the previously computed initialization arguments. The proper name of the newly created class metaobject is set to name. The newly created class metaobject is returned.
If the class argument is a forward referenced class, change-class is called to change its class to the value specified by the :metaclass argument. The class metaobject is then reinitialized with the previously computed initialization arguments. (This is a documented violation of the general constraint that change-class not be used with class metaobjects.)
If the class of the class argument is not the same as the class specified by the :metaclass argument, an error is signaled.
Otherwise, the class metaobject class is redefined by calling the reinitialize-instance generic function with class and the initialization arguments. The class argument is then returned.
Methods:
Primary Method ensure-class-using-class (class class) name &key metaclass direct-superclasses &allow-other-keys
This method implements the behavior of the generic function in the case where the class argument is a class.
This method can be overridden.
Primary Method ensure-class-using-class (class forward-referenced-class) name &key metaclass direct-superclasses &allow-other-keys
This method implements the behavior of the generic function in the case where the class argument is a forward referenced class.
Primary Method ensure-class-using-class (class null) name &key metaclass direct-superclasses &allow-other-keys
This method implements the behavior of the generic function in the case where the class argument is nil.
Function ensure-generic-function
Syntax:
ensure-generic-function function-name &key &allow-other-keys
Arguments:
The function-name argument is a symbol or a list of the form (setf symbol).
Some of the keyword arguments accepted by this function are actually processed by ensure-generic-function-using-class, others are processed during initialization of the generic function metaobject (as described in the section called ``Initialization of Generic Function Metaobjects'').
Values:
The result is a generic function metaobject.
Purpose:
This function is called to define a globally named generic function or to specify or modify options and declarations that pertain to a globally named generic function as a whole. It can be called by the user or the implementation.
It is the functional equivalent of defgeneric, and is called by the expansion of the defgeneric and defmethod macros.
The behavior of this function is actually implemented by the generic function ensure-generic-function-using-class. When ensure-generic-function is called, it immediately calls ensure-generic-function-using-class and returns that result as its own.
The first argument to ensure-generic-function-using-class is computed as follows:
The second argument is function-name. The remaining arguments are the complete set of keyword arguments received by ensure-generic-function.
Generic Function ensure-generic-function-using-class
Syntax:
ensure-generic-function-using-class generic-function function-name &key argument-precedence-order declarations documentation generic-function-class lambda-list method-class method-combination name &allow-other-keys
Arguments:
The generic-function argument is a generic function metaobject or nil.
The function-name argument is a symbol or a list of the form (setf symbol).
The :generic-function-class argument is a class metaobject or a class name. If it is not supplied, it defaults to the class named standard-generic-function. If a class name is supplied, it is interpreted as the class with that name. If a class name is supplied, but there is no such class, an error is signaled.
For the interpretation of additional keyword arguments, see ``Initialization of Generic Function Metaobjects''.
Values:
The result is a generic function metaobject.
Purpose:
The generic function ensure-generic-function-using-class is called to define or modify the definition of a globally named generic function. It is called by the ensure-generic-function function. It can also be called directly.
The first step performed by this generic function is to compute the set of initialization arguments which will be used to create or reinitialize the globally named generic function. These initialization arguments are computed from the full set of keyword arguments received by this generic function as follows:
If the generic-function argument is nil, an instance of the class specified by the :generic-function-class argument is created by calling make-instance with the previously computed initialization arguments. The function name function-name is set to name the generic function. The newly created generic function metaobject is returned.
If the class of the generic-function argument is not the same as the class specified by the :generic-function-class argument, an error is signaled.
Otherwise the generic function generic-function is redefined by calling the reinitialize-instance generic function with generic-function and the initialization arguments. The generic-function argument is then returned.
Methods:
Primary Method ensure-generic-function-using-class (generic-function generic-function) function-name &key generic-function-class &allow-other-keys
This method implements the behavior of the generic function in the case where function-name names an existing generic function.
This method can be overridden.
Primary Method ensure-generic-function-using-class (generic-function null) function-name &key generic-function-class &allow-other-keys
This method implements the behavior of the generic function in the case where function-name names no function, generic function, macro or special form.
Function eql-specializer-object
Syntax:
eql-specializer-object eql-specializer
Arguments:
The eql-specializer argument is an eql specializer metaobject.
Values:
The value returned by this function is an object.
Purpose:
This function returns the object associated with eql-specializer during initialization. The value is guaranteed to be eql to the value originally passed to intern-eql-specializer, but it is not necessarily eq to that value.
This function signals an error if eql-specializer is not an eql specializer.
Function extract-lambda-list
Syntax:
extract-lambda-list specialized-lambda-list
Arguments:
The specialized-lambda-list argument is a specialized lambda list as accepted by def-method.
Values:
The result is an unspecialized lambda list.
Purpose:
This function takes a specialized lambda list and returns the lambda list with the specializers removed. This is a non-destructive operation. Whether the result shares any structure with the argument is unspecified.
If the specialized-lambda-list argument does not have legal syntax, an error is signaled. This syntax checking does not check the syntax of the actual specializer names, only the syntax of the lambda list and where the specializers appear.
Examples:
(extract-lambda-list '((p position))) == (P)
(extract-lambda-list '((p position) x y)) == (P X Y)
(extract-lambda-list '(a (b (eql x)) c &rest i)) == (A B C &OPTIONAL I)
Function extract-specializer-names
Syntax:
extract-specializer-names specialized-lambda-list
Arguments:
The specialized-lambda-list argument is a specialized lambda list as accepted by def-method.
Values:
The result is a list of specializer names.
Purpose:
This function takes a specialized lambda list and returns its specializer names. This is a non-destructive operation. Whether the result shares structure with the argument is unspecified. The results are undefined if the result of this function is modified.
The result of this function will be a list with a number of elements equal to the number of required arguments in specialized-lambda-list. Specializers are defaulted to the symbol t.
If the specialized-lambda-list argument does not have legal syntax, an error is signaled. This syntax checking does not check the syntax of the actual specializer names, only the syntax of the lambda list and where the specializers appear.
Examples:
(extract-specializer-names '((p position))) ==> (POSITION)
(extract-specializer-names '((p position) x y)) ==> (POSITION T T)
(extract-specializer-names '(a (b (eql x)) c &rest i)) ==> (T (EQL X) T)
Generic Function
finalize-inheritanceSyntax:
finalize-inheritance class
Arguments:
The class argument is a class metaobject.
Values:
The value returned by this generic function is unspecified.
Purpose:
This generic function is called to finalize a class metaobject. This is described in the Section named ``Class Finalization Protocol.''
After finalize-inheritance returns, the class metaobject is finalized and the result of calling class-finalized-p on the class metaobject will be true.
Methods:
Primary Method finalize-inheritance (class
standard-class)
Primary Method finalize-inheritance (class
funcallable-standard-class)
No behavior is specified for these methods beyond that which is specified for the generic function.
Primary Method finalize-inheritance (class forward-referenced-class)
This method signals an error.
Generic Function find-method-combination
Syntax:
find-method-combination generic-function method-combination-type-name method-combination-options
Arguments:
The generic-function argument is a generic function metaobject.
The method-combination-type-name argument is a symbol which names a type of method combination.
The method-combination-options argument is a list of arguments to the method combination type.
Values:
The value returned by this generic function is a method combination metaobject.
Purpose:
This generic function is called to determine the method combination object used by a generic function.
Notes:
Further details of method combination metaobjects are not specified.
Function funcallable-standard-instance-access
Syntax:
funcallable-standard-instance-access instance location
Arguments:
The instance argument is an object.
The location argument is a slot location.
Values:
The result of this function is an object.
Purpose:
This function is called to provide direct access to a slot in an instance. By usurping the normal slot lookup protocol, this function is intended to provide highly optimized access to the slots associated with an instance.
The following restrictions apply to the use of this function:
The results are undefined if any of these restrictions are not met.
Generic Function generic-function-...
The following generic functions are described together under ``Readers for Generic Function Metaobjects'': generic-function-argument-precedence-order, generic-function-declarations, generic-function-lambda-list, generic-function-method-class, generic-function-method-combination, generic-function-methods and generic-function-name.
Initialization of Class Metaobjects
A class metaobject can be created by calling make-instance. The initialization arguments establish the definition of the class. A class metaobject can be redefined by calling reinitialize-instance. Some classes of class metaobject do not support redefinition; in these cases, reinitialize-instance signals an error.
Initialization of a class metaobject must be done by calling make-instance and allowing it to call initialize-instance. Reinitialization of a class metaobject must be done by calling reinitialize-instance. Portable programs must not call initialize-instance directly to initialize a class metaobject. Portable programs must not call shared-initialize directly to initialize or reinitialize a class metaobject. Portable programs must not call change-class to change the class of any class metaobject or to turn a non-class object into a class metaobject.
Since metaobject classes may not be redefined, no behavior is specified for the result of calls to update-instance-for-redefined-class on class metaobjects. Since the class of class metaobjects may not be changed, no behavior is specified for the result of calls to update-instance-for-different-class on class metaobjects.
During initialization or reinitialization, each initialization argument is checked for errors and then associated with the class metaobject. The value can then be accessed by calling the appropriate accessor as shown in Table 1.
This section begins with a description of the error checking and processing of each initialization argument. This is followed by a table showing the generic functions that can be used to access the stored initialization arguments. Initialization behavior specific to the different specified class metaobject classes comes next. The section ends with a set of restrictions on portable methods affecting class metaobject initialization and reinitialization.
In these descriptions, the phrase ``this argument defaults to value'' means that when that initialization argument is not supplied, initialization or reinitialization is performed as if value had been supplied. For some initialization arguments this could be done by the use of default initialization arguments, but whether it is done this way is not specified. Implementations are free to define default initialization arguments for specified class metaobject classes. Portable programs are free to define default initialization arguments for portable subclasses of the class class.
Unless there is a specific note to the contrary, then during reinitialization, if an initialization argument is not supplied, the previously stored value is left unchanged.
An error is signaled if this value is not a proper list, or if any element of the list is not a canonicalized default initialization argument.
If the class metaobject is being initialized, this argument defaults to the empty list.
An error is signaled if this value is not a proper list or if any element of the list is not a canonicalized slot specification.
After error checking, this value is converted to a list of direct slot definition metaobjects before it is associated with the class metaobject. Conversion of each canonicalized slot specification to a direct slot definition metaobject is a two-step process. First, the generic function direct-slot-definition-class is called with the class metaobject and the canonicalized slot specification to determine the class of the new direct slot definition metaobject; this permits both the class metaobject and the canonicalized slot specification to control the resulting direct slot definition metaobject class. Second, make-instance is applied to the direct slot definition metaobject class and the canonicalized slot specification. This conversion could be implemented as shown in the following code:
(defun convert-to-direct-slot-definition (class canonicalized-slot) (apply #'make-instance (apply #'direct-slot-definition-class class canonicalized-slot) canonicalized-slot))
If the class metaobject is being initialized, this argument defaults to the empty list.
Once the direct slot definition metaobjects have been created, the specified reader and writer methods are created. The generic functions reader-method-class and writer-method-class are called to determine the classes of the method metaobjects created.
An error is signaled if this value is not a proper list or if validate-superclass applied to class and any element of this list returns false.
When the class metaobject is being initialized, and this argument is either not supplied or is the empty list, this argument defaults as follows: if the class is an instance of standard-class or one of its subclasses the default value is a list of the class standard-object; if the class is an instance of funcallable-standard-class or one of its subclasses the default value is list of the class funcallable-standard-object.
After any defaulting of the value, the generic function add-direct-subclass is called once for each element of the list.
When the class metaobject is being reinitialized and this argument is supplied, the generic function remove-direct-subclass is called once for each class metaobject in the previously stored value but not in the new value; the generic function add-direct-subclass is called once for each class metaobject in the new value but not in the previously stored value.
An error is signaled if this value is not a string or nil.
If the class metaobject is being initialized, this argument defaults to nil.
If the class is being initialized, this argument defaults to nil.
After the processing and defaulting of initialization arguments described above, the value of each initialization argument is associated with the class metaobject. These values can then be accessed by calling the corresponding generic function. The correspondences are as follows:
Initialization Argument | Generic Function |
---|---|
:direct-default-initargs | class-direct-default-initargs |
:direct-slots | class-direct-slots |
:direct-superclasses | class-direct-superclasses |
:documentation | documentation |
:name | class-name |
Instances of the class standard-class support multiple inheritance and reinitialization. Instances of the class funcallable-standard-class support multiple inheritance and reinitialization. For forward referenced classes, all of the initialization arguments default to nil.
Since built-in classes cannot be created or reinitialized by the user, an error is signaled if initialize-instance or reinitialize-instance are called to initialize or reinitialize a derived instance of the class built-in-class.
Methods:
It is not specified which methods provide the initialization and reinitialization behavior described above. Instead, the information needed to allow portable programs to specialize this behavior is presented as a set of restrictions on the methods a portable program can define. The model is that portable initialization methods have access to the class metaobject when either all or none of the specified initialization has taken effect.
These restrictions govern the methods that a portable program can define on the generic functions initialize-instance, reinitialize-instance, and shared-initialize. These restrictions apply only to methods on these generic functions for which the first specializer is a subclass of the class class. Other portable methods on these generic functions are not affected by these restrictions.
The results are undefined if any of these restrictions are violated.
Initialization of Generic Function Metaobjects
A generic function metaobject can be created by calling make-instance. The initialization arguments establish the definition of the generic function. A generic function metaobject can be redefined by calling reinitialize-instance. Some classes of generic function metaobject do not support redefinition; in these cases, reinitialize-instance signals an error.
Initialization of a generic function metaobject must be done by calling make-instance and allowing it to call initialize-instance. Reinitialization of a generic-function metaobject must be done by calling reinitialize-instance. Portable programs must not call initialize-instance directly to initialize a generic function metaobject. Portable programs must not call shared-initialize directly to initialize or reinitialize a generic function metaobject. Portable programs must not call change-class to change the class of any generic function metaobject or to turn a non-generic-function object into a generic function metaobject.
Since metaobject classes may not be redefined, no behavior is specified for the result of calls to update-instance-for-redefined-class on generic function metaobjects. Since the class of a generic function metaobject may not be changed, no behavior is specified for the results of calls to update-instance-for-different-class on generic function metaobjects.
During initialization or reinitialization, each initialization argument is checked for errors and then associated with the generic function metaobject. The value can then be accessed by calling the appropriate accessor as shown in Table 3.
This section begins with a description of the error checking and processing of each initialization argument. This is followed by a table showing the generic functions that can be used to access the stored initialization arguments. The section ends with a set of restrictions on portable methods affecting generic function metaobject initialization and reinitialization.
In these descriptions, the phrase ``this argument defaults to value'' means that when that initialization argument is not supplied, initialization or reinitialization is performed as if value had been supplied. For some initialization arguments this could be done by the use of default initialization arguments, but whether it is done this way is not specified. Implementations are free to define default initialization arguments for specified generic function metaobject classes. Portable programs are free to define default initialization arguments for portable subclasses of the class generic-function.
Unless there is a specific note to the contrary, then during reinitialization, if an initialization argument is not supplied, the previously stored value is left unchanged.
An error is signaled if this argument appears but the :lambda-list argument does not appear. An error is signaled if this value is not a proper list or if this value is not a permutation of the symbols from the required arguments part of the :lambda-list initialization argument.
When the generic function is being initialized or reinitialized, and this argument is not supplied, but the :lambda-list argument is supplied, this value defaults to the symbols from the required arguments part of the :lambda-list argument, in the order they appear in that argument. If neither argument is supplied, neither are initialized (see the description of :lambda-list.)
An error is signaled if this value is not a proper list or if each of its elements is not a legal declaration.
When the generic function is being initialized, and this argument is not supplied, it defaults to the empty list.
An error is signaled if this value is not a string or nil.
If the generic function is being initialized, this argument defaults to nil.
An error is signaled if this value is not a proper generic function lambda list.
When the generic function is being initialized, and this argument is not supplied, the generic function's lambda list is not initialized. The lambda list will be initialized later, either when the first method is added to the generic function, or a later reinitialization of the generic function.
An error is signaled if this value is not a subclass of the class method.
When the generic function is being initialized, and this argument is not supplied, it defaults to the class standard-method.
If the generic function is being initialized, this argument defaults to nil.
After the processing and defaulting of initialization arguments described above, the value of each initialization argument is associated with the generic function metaobject. These values can then be accessed by calling the corresponding generic function. The correspondences are as follows:
Initialization Argument | Generic Function |
---|---|
:argument-precedence-order | generic-function-argument-precedence-order |
:declarations | generic-function-declarations |
:documentation | documentation |
:lambda-list | generic-function-lambda-list |
:method-combination | generic-function-method-combination |
:method-class | generic-function-method-class |
:name | generic-function-name |
Methods:
It is not specified which methods provide the initialization and reinitialization behavior described above. Instead, the information needed to allow portable programs to specialize this behavior is presented as a set of restrictions on the methods a portable program can define. The model is that portable initialization methods have access to the generic function metaobject when either all or none of the specified initialization has taken effect.
These restrictions govern the methods that a portable program can define on the generic functions initialize-instance, reinitialize-instance, and shared-initialize. These restrictions apply only to methods on these generic functions for which the first specializer is a subclass of the class generic-function. Other portable methods on these generic functions are not affected by these restrictions.
The results are undefined if any of these restrictions are violated.
Initialization of Method Metaobjects
A method metaobject can be created by calling make-instance. The initialization arguments establish the definition of the method. A method metaobject cannot be redefined; calling reinitialize-instance signals an error.
Initialization of a method metaobject must be done by calling make-instance and allowing it to call initialize-instance. Portable programs must not call initialize-instance directly to initialize a method metaoject. Portable programs must not call shared-initialize directly to initialize a method metaobject. Portable programs must not call change-class to change the class of any method metaobject or to turn a non-method object into a method metaobject.
Since metaobject classes may not be redefined, no behavior is specified for the result of calls to update-instance-for-redefined-class on method metaobjects. Since the class of a method metaobject cannot be changed, no behavior is specified for the result of calls to update-instance-for-different-class on method metaobjects.
During initialization, each initialization argument is checked for errors and then associated with the method metaobject. The value can then be accessed by calling the appropriate accessor as shown in Table 4.
This section begins with a description of the error checking and processing of each initialization argument. This is followed by a table showing the generic functions that can be used to access the stored initialization arguments. The section ends with a set of restrictions on portable methods affecting method metaobject initialization.
In these descriptions, the phrase ``this argument defaults to value'' means that when that initialization argument is not supplied, initialization is performed as if value had been supplied. For some initialization arguments this could be done by the use of default initialization arguments, but whether it is done this way is not specified. Implementations are free to define default initialization arguments for specified method metaobject classes. Portable programs are free to define default initialization arguments for portable subclasses of the class method.
After the processing and defaulting of initialization arguments described above, the value of each initialization argument is associated with the method metaobject. These values can then be accessed by calling the corresponding generic function. The correspondences are as follows:
Initialization Argument | Generic Function |
---|---|
:qualifiers | method-qualifiers |
:lambda-list | method-lambda-list |
:specializers | method-specializers |
:function | method-function |
:slot-definition | accessor-method-slot-definition |
:documentation | documentation |
Methods:
It is not specified which methods provide the initialization behavior described above. Instead, the information needed to allow portable programs to specialize this behavior is presented in as a set of restrictions on the methods a portable program can define. The model is that portable initialization methods have access to the method metaobject when either all or none of the specified initialization has taken effect.
These restrictions govern the methods that a portable program can define on the generic functions initialize-instance, reinitialize-instance, and shared-initialize. These restrictions apply only to methods on these generic functions for which the first specializer is a subclass of the class method. Other portable methods on these generic functions are not affected by these restrictions.
The results are undefined if any of these restrictions are violated.
Initialization of Slot Definition Metaobjects
A slot definition metaobject can be created by calling make-instance. The initialization arguments establish the definition of the slot definition. A slot definition metaobject cannot be redefined; calling reinitialize-instance signals an error.
Initialization of a slot definition metaobject must be done by calling make-instance and allowing it to call initialize-instance. Portable programs must not call initialize-instance directly to initialize a slot definition metaobject. Portable programs must not call shared-initialize directly to initialize a slot definition metaobject. Portable programs must not call change-class to change the class of any slot definition metaobject or to turn a non-slot-definition object into a slot definition metaobject.
Since metaobject classes may not be redefined, no behavior is specified for the result of calls to update-instance-for-redefined-class on slot definition metaobjects. Since the class of a slot definition metaobject cannot be changed, no behavior is specified for the result of calls to update-instance-for-different-class on slot definition metaobjects.
During initialization, each initialization argument is checked for errors and then associated with the slot definition metaobject. The value can then be accessed by calling the appropriate accessor as shown in Table 4.
This section begins with a description of the error checking and processing of each initialization argument. This is followed by a table showing the generic functions that can be used to access the stored initialization arguments.
In these descriptions, the phrase ``this argument defaults to value'' means that when that initialization argument is not supplied, initialization is performed as if value had been supplied. For some initialization arguments this could be done by the use of default initialization arguments, but whether it is done this way is not specified. Implementations are free to define default initialization arguments for specified slot definition metaobject classes. Portable programs are free to define default initialization arguments for portable subclasses of the class slot-definition.
After the processing and defaulting of initialization arguments described above, the value of each initialization argument is associated with the slot definition metaobject. These values can then be accessed by calling the corresponding generic function. The correspondences are as follows:
Initialization Argument | Generic Function |
---|---|
:name | slot-definition-name |
:initform | slot-definition-initform |
:initfunction | slot-definition-initfunction |
:type | slot-definition-type |
:allocation | slot-definition-allocation |
:initargs | slot-definition-initargs |
:readers | slot-definition-readers |
:writers | slot-definition-writers |
:documentation | documentation |
Methods:
It is not specified which methods provide the initialization and reinitialization behavior described above. Instead, the information needed to allow portable programs to specialize this behavior is presented as a set of restrictions on the methods a portable program can define. The model is that portable initialization methods have access to the slot definition metaobject when either all or none of the specified initialization has taken effect.
These restrictions govern the methods that a portable program can define on the generic functions initialize-instance, reinitialize-instance, and shared-initialize. These restrictions apply only to methods on these generic functions for which the first specializer is a subclass of the class slot-definition. Other portable methods on these generic functions are not affected by these restrictions.
The results are undefined if any of these restrictions are violated.
Function intern-eql-specializer
Syntax:
intern-eql-specializer object
Arguments:
The object argument is any Lisp object.
Values:
The result is the eql specializer metaobject for object.
Purpose:
This function returns the unique eql specializer metaobject for object, creating one if necessary. Two calls to intern-eql-specializer with eql arguments will return the same (i.e., eq) value.
Notes:
The result of calling eql-specializer-object on the result of a call to intern-eql-special-izer is only guaranteed to be eql to the original object argument, not necessarily eq.
Generic Function make-instance
Syntax:
make-instance class &rest initargs
Arguments:
The class argument is a class metaobject or a class name.
The initargs argument is a list of alternating initialization argument names and values.
Values:
The result is a newly allocated and initialized instance of class.
Purpose:
The generic function make-instance creates and returns a new instance of the given class. Its behavior and use is described in the CLOS specification.
Methods:
Primary Method make-instance (class symbol) &rest initargs
This method simply invokes make-instance recursively on the arguments (find-class class) and initargs.
Primary Method make-instance (class standard-class) &rest
initargs
Primary Method make-instance (class funcallable-standard-class) &rest
initargs
These methods implement the behavior of make-instance described in the CLOS specification section named ``Object Creation and Initialization.''
Generic Function make-method-lambda
Syntax:
make-method-lambda generic-function method lambda-expression environment
Arguments:
The generic-function argument is a generic function metaobject.
The method argument is a (possibly uninitialized) method metaobject.
The lambda-expression argument is a lambda expression.
The environment argument is the same as the &environment argument to macro expansion functions.
Values:
This generic function returns two values. The first is a lambda expression, the second is a list of initialization arguments and values.
Purpose:
This generic function is called to produce a lambda expression which can itself be used to produce a method function for a method and generic function with the specified classes. The generic function and method the method function will be used with are not required to be the given ones. Moreover, the method metaobject may be uninitialized.
Either the function compile, the special form function or the function coerce must be used to convert the lambda expression to a method function. The method function itself can be applied to arguments with apply or funcall.
When a method is actually called by an effective method, its first argument will be a list of the arguments to the generic function. Its remaining arguments will be all but the first argument passed to call-method. By default, all method functions must accept two arguments: the list of arguments to the generic function and the list of next methods.
For a given generic function and method class, the applicable methods on make-method-lambda and compute-effective-method must be consistent in the following way: each use of call-method returned by the method on compute-effective-method must have the same number of arguments, and the method lambda returned by the method on make-method-lambda must accept a corresponding number of arguments.
Note that the system-supplied implementation of call-next-method is not required to handle extra arguments to the method function. Users who define additional arguments to the method function must either redefine or forego call-next-method. (See the example below.)
When the method metaobject is created with make-instance, the method function must be the value of the :function initialization argument. The additional initialization arguments, returned as the second value of this generic function, must also be passed in this call to make-instance.
Methods:
Primary Method make-method-lambda (generic-function standard-generic-function) (method standard-method) lambda-expression environment
This method returns a method lambda which accepts two arguments, the list of arguments to the generic function, and the list of next methods. What initialization arguments may be returned in the second value are unspecified.
This method can be overridden.
This example shows how to define a kind of method which, from within the body of the method, has access to the actual method metaobject for the method. This simplified code overrides whatever method combination is specified for the generic function, implementing a simple method combination supporting only primary methods, call-next-method and next-method-p. (In addition, its a simplified version of call-next-method which does no error checking.)
Notice that the extra lexical function bindings get wrapped around the body before call-next-method is called. In this way, the user's definition of call-next-method and next-method-p are sure to override the system's definitions.
(defclass my-generic-function (standard-generic-function) () (:default-initargs :method-class (find-class 'my-method)))
(defclass my-method (standard-method) ())
(defmethod make-method-lambda ((gf my-generic-function) (method my-method) lambda-expression environment) (declare (ignore environment)) `(lambda (args next-methods this-method) (,(call-next-method gf method `(lambda ,(cadr lambda-expression) (flet ((this-method () this-method) (call-next-method (&rest cnm-args) (funcall (method-function (car next-methods)) (or cnm-args args) (cdr next-methods) (car next-methods))) (next-method-p () (not (null next-methods)))) ,@(cddr lambda-expression))) environment) args next-methods)))
(defmethod compute-effective-method ((gf my-generic-function) method-combination methods) `(call-method ,(car methods) ,(cdr methods) ,(car methods)))
Generic Function
map-dependentsSyntax:
map-dependents metaobject function
Arguments:
The metaobject argument is a class or generic function metaobject.
The function argument is a function which accepts one argument.
Values:
The value returned is unspecified.
Purpose:
This generic function applies function to each of the dependents of metaobject. The order in which the dependents are processed is not specified, but function is applied to each dependent once and only once. If, during the mapping, add-dependent or remove-dependent is called to alter the dependents of metaobject, it is not specified whether the newly added or removed dependent will have function applied to it.
Methods:
Primary Method map-dependents (metaobject standard-class) function
This method has no specified behavior beyond that which is specified for the generic function.
This method cannot be overridden unless the following methods are overridden as well:
add-dependent (standard-class t)
remove-dependent (standard-class t)
Primary Method map-dependents (metaobject funcallable-standard-class) function
This method has no specified behavior beyond that which is specified for the generic function.
This method cannot be overridden unless the following methods are overridden as well:
add-dependent (funcallable-standard-class t)
remove-dependent (funcallable-standard-class t)
Primary Method map-dependents (metaobject standard-generic-function) function
This method has no specified behavior beyond that which is specified for the generic function.
This method cannot be overridden unless the following methods are overridden as well:
add-dependent (standard-generic-function t)
remove-dependent (standard-generic-function t)
Notes:
See the ``Dependent Maintenance Protocol'' section for remarks about the use of this facility.
Generic Function method-...
The following generic functions are described together under ``Readers for Method Metaobjects'': method-function, method-generic-function, method-lambda-list, method-specializers, method-qualifiers and accessor-method-slot-definition.
Readers for Class Metaobjects
In this and the immediately following sections, the ``reader'' generic functions which simply return information associated with a particular kind of metaobject are presented together. General information is presented first, followed by a description of the purpose of each, and ending with the specified methods for these generic functions.
The reader generic functions which simply return information associated with class metaobjects are presented together in this section.
Each of the reader generic functions for class metaobjects has the same syntax, accepting one required argument called class, which must be an class metaobject; otherwise, an error is signaled. An error is also signaled if the class metaobject has not been initialized.
These generic functions can be called by the user or the implementation.
For any of these generic functions which returns a list, such lists will not be mutated by the implementation. The results are undefined if a portable program allows such a list to be mutated.
Generic Function class-default-initargs class
Returns a list of the default initialization arguments for class. Each element of this list is a canonicalized default initialization argument. The empty list is returned if class has no default initialization arguments.
During finalization finalize-inheritance calls compute-default-initargs to compute the default initialization arguments for the class. That value is associated with the class metaobject and is returned by class-default-initargs.
This generic function signals an error if class has not been finalized.
Generic Function class-direct-default-initargs class
Returns a list of the direct default initialization arguments for class. Each element of this list is a canonicalized default initialization argument. The empty list is returned if class has no direct default initialization arguments. This is the defaulted value of the :direct-default-initargs initialization argument that was associated with the class during initialization or reinitialization.
Generic Function class-direct-slots class
Returns a set of the direct slots of class. The elements of this set are direct slot definition metaobjects. If the class has no direct slots, the empty set is returned. This is the defaulted value of the :direct-slots initialization argument that was associated with the class during initialization and reinitialization.
Generic Function class-direct-subclasses class
Returns a set of the direct subclasses of class. The elements of this set are class metaobjects that all mention this class among their direct superclasses. The empty set is returned if class has no direct subclasses. This value is maintained by the generic functions add-direct-subclass and remove-direct-subclass.
Generic Function class-direct-superclasses class
Returns a list of the direct superclasses of class. The elements of this list are class metaobjects. The empty list is returned if class has no direct superclasses. This is the defaulted value of the :direct-superclasses initialization argument that was associated with the class during initialization or reinitialization.
Generic Function class-finalized-p class
Returns true if class has been finalized. Returns false otherwise. Also returns false if the class has not been initialized.
Generic Function class-name class
Returns the name of class. This value can be any Lisp object, but is usually a symbol, or nil if the class has no name. This is the defaulted value of the :name initialization argument that was associated with the class during initialization or reinitialization. (Also see (setf class-name).)
Generic Function class-precedence-list class
Returns the class precedence list of class. The elements of this list are class metaobjects.
During class finalization finalize-inheritance calls compute-class-precedence-list to compute the class precedence list of the class. That value is associated with the class metaobject and is returned by class-precedence-list.
This generic function signals an error if class has not been finalized.
Generic Function class-prototype class
Returns a prototype instance of class. Whether the instance is initialized is not specified. The results are undefined if a portable program modifies the binding of any slot of prototype instance.
This generic function signals an error if class has not been finalized.
Generic Function class-slots class
Returns a possibly empty set of the slots accessible in instances of class. The elements of this set are effective slot definition metaobjects.
During class finalization finalize-inheritance calls compute-slots to compute the slots of the class. That value is associated with the class metaobject and is returned by class-slots.
This generic function signals an error if class has not been finalized.
Methods:
The specified methods for the class metaobject reader generic functions are presented below.
Each entry in the table indicates a method on one of the reader generic functions, specialized to a specified class. The number in each entry is a reference to the full description of the method. The full descriptions appear after the table.
standard-class and funcallable-standard-class |
forward-referenced-class | built-in-class | |
---|---|---|---|
class-default-initargs | 2 | 3 | 4 |
class-direct-default-initargs | 1 | 4 | 4 |
class-direct-slots | 1 | 4 | 4 |
class-direct-subclasses | 9 | 9 | 7 |
class-direct-superclasses | 1 | 4 | 7 |
class-finalized-p | 2 | 6 | 5 |
class-name | 1 | 1 | 8 |
class-precedence-list | 2 | 3 | 7 |
class-prototype | 10 | 10 | 10 |
class-slots | 2 | 3 | 4 |
Readers for Generic Function Metaobjects
The reader generic functions which simply return information associated with generic function metaobjects are presented together in this section.
Each of the reader generic functions for generic function metaobjects has the same syntax, accepting one required argument called generic-function, which must be a generic function metaobject; otherwise, an error is signaled. An error is also signaled if the generic function metaobject has not been initialized.
These generic functions can be called by the user or the implementation.
The list returned by this generic function will not be mutated by the implementation. The results are undefined if a portable program mutates the list returned by this generic function.
Generic Function generic-function-argument-precedence-order generic-function
Returns the argument precedence order of the generic function. This value is a list of symbols, a permutation of the required parameters in the lambda list of the generic function. This is the defaulted value of the :argument-precedence-order initialization argument that was associated with the generic function metaobject during initialization or reinitialization.
Generic Function generic-function-declarations generic-function
Returns a possibly empty list of the declarations of the generic function. The elements of this list are declarations. This list is the defaulted value of the :declarations initialization argument that was associated with the generic function metaobject during initialization or reinitialization.
Generic Function generic-function-lambda-list generic-function
Returns the lambda list of the generic function. This is the defaulted value of the :lambda-list initialization argument that was associated with the generic function metaobject during initialization or reinitialization. An error is signaled if the lambda list has yet to be supplied.
Generic Function generic-function-method-class generic-function
Returns the default method class of the generic function. This class must be a subclass of the class method. This is the defaulted value of the :method-class initialization argument that was associated with the generic function metaobject during initialization or reinitialization.
Generic Function generic-function-method-combination generic-function
Returns the method combination of the generic function. This is a method combination metaobject. This is the defaulted value of the :method-combination initialization argument that was associated with the generic function metaobject during initialization or reinitialization.
Generic Function generic-function-methods generic-function
Returns the set of methods currently connected to the generic function. This is a set of method metaobjects. This value is maintained by the generic functions add-method and remove-method.
Generic Function generic-function-name generic-function
Returns the name of the generic function, or nil if the generic function has no name. This is the defaulted value of the :name initialization argument that was associated with the generic function metaobject during initialization or reinitialization. (Also see (setf generic-function-name).)
Methods:
The specified methods for the generic function metaobject reader generic functions are presented below.
Primary Method generic-function-argument-precedence-order (generic-function
standard-generic-function)
Primary Method generic-function-declarations (generic-function
standard-generic-function)
Primary Method generic-function-lambda-list (generic-function
standard-generic-function)
Primary Method generic-function-method-class (generic-function
standard-generic-function)
Primary Method generic-function-method-combination (generic-function
standard-generic-function)
Primary Method generic-function-name (generic-function
standard-generic-function)
No behavior is specified for these methods beyond that which is specified for their respective generic functions.
Primary Method generic-function-methods (generic-function standard-generic-function)
No behavior is specified for this method beyond that which is specified for their respective generic functions.
The value returned by this method is maintained by add-method (standard-generic-function standard-method) and remove-method (standard-generic-function standard-method).
Readers for Method Metaobjects
The reader generic functions which simply return information associated with method metaobjects are presented together here in the format described under ``Readers for Class Metaobjects.''
Each of these reader generic functions have the same syntax, accepting one required argument called method, which must be a method metaobject; otherwise, an error is signaled. An error is also signaled if the method metaobject has not been initialized.
These generic functions can be called by the user or the implementation.
For any of these generic functions which returns a list, such lists will not be mutated by the implementation. The results are undefined if a portable program allows such a list to be mutated.
Generic Function method-function method
Returns the method function of method. This is the defaulted value of the :function initialization argument that was associated with the method during initialization.
Generic Function method-generic-function method
Returns the generic function that method is currently connected to, or nil if it is not currently connected to any generic function. This value is either a generic function metaobject or nil. When a method is first created it is not connected to any generic function. This connection is maintained by the generic functions add-method and remove-method.
Generic Function method-lambda-list method
Returns the (unspecialized) lambda list of method. This value is a Common Lisp lambda list. This is the defaulted value of the :lambda-list initialization argument that was associated with the method during initialization.
Generic Function method-specializers method
Returns a list of the specializers of method. This value is a list of specializer metaobjects. This is the defaulted value of the :specializers initialization argument that was associated with the method during initialization.
Generic Function method-qualifiers method
Returns a (possibly empty) list of the qualifiers of method. This value is a list of non-nil atoms. This is the defaulted value of the :qualifiers initialization argument that was associated with the method during initialization.
Generic Function accessor-method-slot-definition method
This accessor can only be called on accessor methods. It returns the direct slot definition metaobject that defined this method. This is the value of the :slot-definition initialization argument associated with the method during initialization.
Methods:
The specified methods for the method metaobject readers are presented below.
Primary Method method-function (method standard-method)
Primary Method method-lambda-list (method standard-method)
Primary Method method-specializers (method standard-method)
Primary Method method-qualifiers (method standard-method)
No behavior is specified for these methods beyond that which is specified for their respective generic functions.
Primary Method method-generic-function (method standard-method)
No behavior is specified for this method beyond that which is specified for its generic function.
The value returned by this method is maintained by add-method (standard-generic-function standard-method) and remove-method (standard-generic-function standard-method).
Primary Method accessor-method-slot-definition (method standard-accessor-method)
No behavior is specified for this method beyond that which is specified for its generic function.
Readers for Slot Definition Metaobjects
The reader generic functions which simply return information associated with slot definition metaobjects are presented together here in the format described under ``Readers for Class Metaobjects.''
Each of the reader generic functions for slot definition metaobjects has the same syntax, accepting one required argument called slot, which must be a slot definition metaobject; otherwise, an error is signaled. An error is also signaled if the slot definition metaobject has not been initialized.
These generic functions can be called by the user or the implementation.
For any of these generic functions which returns a list, such lists will not be mutated by the implementation. The results are undefined if a portable program allows such a list to be mutated.
Generic Functions:
Generic Function slot-definition-allocation slot
Returns the allocation of slot. This is a symbol. This is the defaulted value of the :allocation initialization argument that was associated with the slot definition metaobject during initialization.
Generic Function slot-definition-initargs slot
Returns the set of initialization argument keywords for slot. This is the defaulted value of the :initargs initialization argument that was associated with the slot definition metaobject during initialization.
Generic Function slot-definition-initform slot
Returns the initialization form of slot. This can be any form. This is the defaulted value of the :initform initialization argument that was associated with the slot definition metaobject during initialization. When slot has no initialization form, the value returned is unspecified (however, slot-definition-initfunction is guaranteed to return nil).
Generic Function slot-definition-initfunction slot
Returns the initialization function of slot. This value is either a function of no arguments, or nil, indicating that the slot has no initialization function. This is the defaulted value of the :initfunction initialization argument that was associated with the slot definition metaobject during initialization.
Generic Function slot-definition-name slot
Returns the name of slot. This value is a symbol that can be used as a variable name. This is the value of the :name initialization argument that was associated with the slot definition metaobject during initialization.
Generic Function slot-definition-type slot
Returns the type of slot. This is a type specifier name. This is the defaulted value of the :type initialization argument that was associated with the slot definition metaobject during initialization.
Methods:
The specified methods for the slot definition metaobject readers are presented below.
Primary Method slot-definition-allocation (slot-definition
standard-slot-definition)
Primary Method slot-definition-initargs (slot-definition
standard-slot-definition)
Primary Method slot-definition-initform (slot-definition
standard-slot-definition)
Primary Method slot-definition-initfunction (slot-definition
standard-slot-definition)
Primary Method slot-definition-name (slot-definition
standard-slot-definition)
Primary Method slot-definition-type (slot-definition
standard-slot-definition)
No behavior is specified for these methods beyond that which is specified for their respective generic functions.
Direct Slot Definition Metaobjects:
The following additional reader generic functions are defined for direct slot definition metaobjects.
Generic Function slot-definition-readers direct-slot
Returns a (possibly empty) set of readers of the direct slot. This value is a list of function names. This is the defaulted value of the :readers initialization argument that was associated with the direct slot definition metaobject during initialization.
Generic Function slot-definition-writers direct-slot
Returns a (possibly empty) set of writers of the direct slot. This value is a list of function names. This is the defaulted value of the :writers initialization argument that was associated with the direct slot definition metaobject during initialization.
Primary Method slot-definition-readers (direct-slot-definition
standard-direct-slot-definition)
Primary Method slot-definition-writers (direct-slot-definition
standard-direct-slot-definition)
No behavior is specified for these methods beyond what is specified for their generic functions.
Effective Slot Definition Metaobjects:
The following reader generic function is defined for effective slot definition metaobjects.
Generic Function slot-definition-location effective-slot-definition
Returns the location of effective-slot-definition. The meaning and interpretation of this value is described in the section called ``Instance Structure Protocol.''
Primary Method slot-definition-location (effective-slot-definition standard-effective-slot-definition)
This method returns the value stored by
Around Method compute-slots (standard-class)
and
Around Method compute-slots (funcallable-standard-class).
Generic Function reader-method-class
Syntax:
reader-method-class class direct-slot &rest initargs
Arguments:
The class argument is a class metaobject.
The direct-slot argument is a direct slot definition metaobject.
The initargs argument consists of alternating initialization argument names and values.
Values:
The value returned is a class metaobject.
Purpose:
This generic function is called to determine the class of reader methods created during class initialization and reinitialization. The result must be a subclass of standard-reader-method.
The initargs argument must be the same as will be passed to make-instance to create the reader method. The initargs must include :slot-definition with slot-definition as its value.
Methods:
Primary Method reader-method-class (class standard-class) (direct-slot standard-direct-slot-definition) &rest initargs
Primary Method reader-method-class (class funcallable-standard-class) (direct-slot standard-direct-slot-definition) &rest initargs
These methods return the class standard-reader-method. These methods can be overridden.
Generic Function
remove-dependentSyntax:
remove-dependent metaobject dependent
Arguments:
The metaobject argument is a class or generic function metaobject.
The dependent argument is an object.
Values:
The value returned by this generic function is unspecified.
Purpose:
This generic function removes dependent from the dependents of metaobject. If dependent is not one of the dependents of metaobject, no error is signaled.
The generic function map-dependents can be called to access the set of dependents of a class or generic function. The generic function add-dependent can be called to add an object from the set of dependents of a class or generic function. The effect of calling add-dependent or remove-dependent while a call to map-dependents on the same class or generic function is in progress is unspecified.
The situations in which remove-dependent is called are not specified.
Methods:
Primary Method remove-dependent (class standard-class) dependent
No behavior is specified for this method beyond that which is specified for the generic function.
This method cannot be overridden unless the following methods are overridden as well:
add-dependent (standard-class t)
map-dependents (standard-class t)
Primary Method remove-dependent (class funcallable-standard-class) dependent
No behavior is specified for this method beyond that which is specified for the generic function.
This method cannot be overridden unless the following methods are overridden as well:
add-dependent (funcallable-standard-class t)
map-dependents (funcallable-standard-class t)
Primary Method remove-dependent (generic-function standard-generic-function) dependent
No behavior is specified for this method beyond that which is specified for the generic function.
This method cannot be overridden unless the following methods are overridden as well:
add-dependent (standard-generic-function t)
map-dependents (standard-generic-function t)
Notes:
See the ``Dependent Maintenance Protocol'' section for remarks about the use of this facility.
Generic Function remove-direct-method
Syntax:
remove-direct-method specializer method
Arguments:
The specializer argument is a specializer metaobject.
The method argument is a method metaobject.
Values:
The value returned by remove-direct-method is unspecified.
Purpose:
This generic function is called to maintain a set of backpointers from a specializer to the set of methods specialized to it. If method is in the set it is removed. If it is not, no error is signaled.
This set can be accessed as a list by calling the generic function specializer-direct-methods. Methods are added to the set by add-direct-method.
The generic function remove-direct-method is called by remove-method whenever a method is removed from a generic function. It is called once for each of the specializers of the method. Note that in cases where a specializer appears more than once in the specializers of a method, this generic function will be called more than once with the same specializer as argument.
The results are undefined if the specializer argument is not one of the specializers of the method argument.
Methods:
Primary Method remove-direct-method (specializer class) (method method)
This method implements the behavior of the generic function for class specializers. No behavior is specified for this method beyond that which is specified for the generic function.
This method cannot be overridden unless the following methods are overridden as well:
add-direct-method (class method)
specializer-direct-generic-functions (class)
specializer-direct-methods (class)
Primary Method remove-direct-method (specializer eql-specializer) (method method)
This method implements the behavior of the generic function for eql specializers. No behavior is specified for this method beyond that which is specified for the generic function.
Generic Function remove-direct-subclass
Syntax:
remove-direct-subclass superclass subclass
Arguments:
The superclass argument is a class metaobject.
The subclass argument is a class metaobject.
Values:
The value returned by this generic function is unspecified.
Purpose:
This generic function is called to maintain a set of backpointers from a class to its direct subclasses. It removes subclass from the set of direct subclasses of superclass. No error is signaled if subclass is not in this set.
Whenever a class is reinitialized, this generic function is called once with each deleted direct superclass of the class.
Methods:
Primary Method remove-direct-subclass (superclass class) (subclass class)
No behavior is specified for this method beyond that which is specified for the generic function.
This method cannot be overridden unless the following methods are overridden as well:
add-direct-subclass (class class)
class-direct-subclasses (class)
Generic Function remove-method
Syntax:
remove-method generic-function method
Arguments:
The generic-function argument is a generic function metaobject.
The method argument is a method metaobject.
Values:
The generic-function argument is returned.
Purpose:
This generic function breaks the association between a generic function and one of its methods.
No error is signaled if the method is not among the methods of the generic function.
Breaking the association between the method and the generic function proceeds in four steps: (i) remove method from the set returned by generic-function-methods and arrange for method-generic-function to return nil; (ii) call remove-direct-method for each of the method's specializers; (iii) call compute-discriminating-function and install its result with set-funcallable-instance-function; and (iv) update the dependents of the generic function.
The generic function remove-method can be called by the user or the implementation.
Methods:
Primary Method remove-method generic-function standard-generic-function) (method standard-method)
No behavior is specified for this method beyond that which is specified for the generic function.
Function set-funcallable-instance-function
Syntax:
set-funcallable-instance-function funcallable-instance function
Arguments:
The funcallable-instance argument is a funcallable instance (it must have been returned by allocate-instance (funcallable-standard-class)).
The function argument is a function.
Values:
The value returned by this function is unspecified.
Purpose:
This function is called to set or to change the function of a funcallable instance. After set-funcallable-instance-function is called, any subsequent calls to funcallable-instance will run the new function.
Function
(setf class-name)Syntax:
(setf class-name) new-name class
Arguments:
The class argument is a class metaobject.
The new-name argument is any Lisp object.
Values:
This function returns its new-name argument.
Purpose:
This function changes the name of class to new-name. This value is usually a symbol, or nil if the class has no name.
This function works by calling reinitialize-instance with class as its first argument, the symbol :name as its second argument and new-name as its third argument.
Function (setf generic-function-name)
Syntax:
(setf generic-function-name) new-name generic-function
Arguments:
The generic-function argument is a generic function metaobject.
The new-name argument is a function name or nil.
Values:
This function returns its new-name argument.
Purpose:
This function changes the name of generic-function to new-name. This value is usually a function name (i.e., a symbol or a list of the form (setf symbol)) or nil, if the generic function is to have no name.
This function works by calling reinitialize-instance with generic-function as its first argument, the symbol :name as its second argument and new-name as its third argument.
Generic Function (setf slot-value-using-class)
Syntax:
(setf slot-value-using-class) new-value class object slot
Arguments:
The new-value argument is an object.
The class argument is a class metaobject. It is the class of the object argument.
The object argument is an object.
The slot argument is an effective slot definition metaobject.
Values:
This generic function returns the new-value argument.
Purpose:
The generic function (setf slot-value-using-class) implements the behavior of the (setf slot-value) function. It is called by (setf slot-value) with the class of object as its second argument and the pertinent effective slot definition metaobject as its fourth argument.
The generic function (setf slot-value-using-class) sets the value contained in the given slot of the given object to the given new value; any previous value is lost.
The results are undefined if the class argument is not the class of the object argument, or if the slot argument does not appear among the set of effective slots associated with the class argument.
Methods:
Primary Method (setf slot-value-using-class) new-value (class standard-class) object (slot standard-effective-slot-definition)
Primary Method (setf slot-value-using-class) new-value (class funcallable-standard-class) object (slot standard-effective-slot-definition)
These methods implement the full behavior of this generic function for slots with allocation :instance and :class. If the supplied slot has an allocation other than :instance or :class an error is signaled.
Overriding these methods is permitted, but may require overriding other methods in the standard implementation of the slot access protocol.
Primary Method (setf slot-value-using-class) new-value (class built-in-class) object slot
This method signals an error.
Generic Function slot-boundp-using-class
Syntax:
slot-boundp-using-class class object slot
Arguments:
The class argument is a class metaobject. It is the class of the object argument.
The object argument is an object.
The slot argument is an effective slot definition metaobject.
Values:
This generic function returns true or false.
Purpose:
This generic function implements the behavior of the slot-boundp function. It is called by slot-boundp with the class of object as its first argument and the pertinent effective slot definition metaobject as its third argument.
The generic function slot-boundp-using-class tests whether a specific slot in an instance is bound.
The results are undefined if the class argument is not the class of the object argument, or if the slot argument does not appear among the set of effective slots associated with the class argument.
Methods:
Primary Method slot-boundp-using-class (class standard-class) object (slot standard-effective-slot-definition)
Primary Method slot-boundp-using-class (class funcallable-standard-class) object (slot standard-effective-slot-definition)
These methods implement the full behavior of this generic function for slots with allocation :instance and :class. If the supplied slot has an allocation other than :instance or :class an error is signaled.
Overriding these methods is permitted, but may require overriding other methods in the standard implementation of the slot access protocol.
Primary Method slot-boundp-using-class (class built-in-class) object slot
This method signals an error.
Notes:
In cases where the class metaobject class does not distinguish unbound slots, true should be returned.
Generic Function slot-definition-...
The following generic functions are described together under ``Readers for Slot Definition Metaobjects'': slot-definition-allocation, slot-definition-initargs, slot-definition-initform, slot-definition-initfunction, slot-definition-location, slot-definition-name, slot-definition-readers, slot-definition-writers and slot-definition-type.
Generic Function slot-makunbound-using-class
Syntax:
slot-makunbound-using-class class object slot
Arguments:
The class argument is a class metaobject. It is the class of the object argument.
The object argument is an object.
The slot argument is an effective slot definition metaobject.
Values:
This generic function returns its object argument.
Purpose:
This generic function implements the behavior of the slot-makunbound function. It is called by slot-makunbound with the class of object as its first argument and the pertinent effective slot definition metaobject as its third argument.
The generic function slot-makunbound-using-class restores a slot in an object to its unbound state. The interpretation of ``restoring a slot to its unbound state'' depends on the class metaobject class.
The results are undefined if the class argument is not the class of the object argument, or if the slot argument does not appear among the set of effective slots associated with the class argument.
Methods:
Primary Method slot-makunbound-using-class (class standard-class) object (slot standard-effective-slot-definition)
Primary Method slot-makunbound-using-class (class funcallable-standard-class) object (slot standard-effective-slot-definition)
These methods implement the full behavior of this generic function for slots with allocation :instance and :class. If the supplied slot has an allocation other than :instance or :class an error is signaled.
Overriding these methods is permitted, but may require overriding other methods in the standard implementation of the slot access protocol.
Primary Method slot-makunbound-using-class (class built-in-class) object slot
This method signals an error.
Generic Function slot-value-using-class
Syntax:
slot-value-using-class class object slot
Arguments:
The class argument is a class metaobject. It is the class of the object argument.
The object argument is an object.
The slot argument is an effective slot definition metaobject.
Values:
The value returned by this generic function is an object.
Purpose:
This generic function implements the behavior of the slot-value function. It is called by slot-value with the class of object as its first argument and the pertinent effective slot definition metaobject as its third argument.
The generic function slot-value-using-class returns the value contained in the given slot of the given object. If the slot is unbound slot-unbound is called.
The results are undefined if the class argument is not the class of the object argument, or if the slot argument does not appear among the set of effective slots associated with the class argument.
Methods:
Primary Method slot-value-using-class (class standard-class) object (slot standard-effective-slot-definition)
Primary Method slot-value-using-class (class funcallable-standard-class) object (slot standard-effective-slot-definition)
These methods implement the full behavior of this generic function for slots with allocation :instance and :class. If the supplied slot has an allocation other than :instance or :class an error is signaled.
Overriding these methods is permitted, but may require overriding other methods in the standard implementation of the slot access protocol.
Primary Method slot-value-using-class (class built-in-class) object slot
This method signals an error.
Generic Function specializer-direct-generic-functions
Syntax:
specializer-direct-generic-functions specializer
Arguments:
The specializer argument is a specializer metaobject.
Values:
The result of this generic function is a possibly empty list of generic function metaobjects.
Purpose:
This generic function returns the possibly empty set of those generic functions which have a method with specializer as a specializer. The elements of this set are generic function metaobjects. This value is maintained by the generic functions add-direct-method and remove-direct-method.
Methods:
Primary Method specializer-direct-generic-functions (specializer class)
No behavior is specified for this method beyond that which is specified for the generic function.
This method cannot be overridden unless the following methods are overridden as well:
add-direct-method (class method)
remove-direct-method (class method)
specializer-direct-methods (class)
Primary Method specializer-direct-generic-functions (specializer eql-specializer)
No behavior is specified for this method beyond that which is specified for the generic function.
Generic Function specializer-direct-methods
Syntax:
specializer-direct-methods specializer
Arguments:
The specializer argument is a specializer metaobject.
Values:
The result of this generic function is a possibly empty list of method metaobjects.
Purpose:
This generic function returns the possibly empty set of those methods, connected to generic functions, which have specializer as a specializer. The elements of this set are method metaobjects. This value is maintained by the generic functions add-direct-method and remove-direct-method.
Methods:
Primary Method specializer-direct-methods (specializer class)
No behavior is specified for this method beyond that which is specified for the generic function.
This method cannot be overridden unless the following methods are overridden as well:
add-direct-method (class method)
remove-direct-method (class method)
specializer-direct-generic-functions (class)
Primary Method specializer-direct-methods (specializer eql-specializer)
No behavior is specified for this method beyond that which is specified for the generic function.
Function standard-instance-access
Syntax:
standard-instance-access instance location
Arguments:
The instance argument is an object.
The location argument is a slot location.
Values:
The result of this function is an object.
Purpose:
This function is called to provide direct access to a slot in an instance. By usurping the normal slot lookup protocol, this function is intended to provide highly optimized access to the slots associated with an instance.
The following restrictions apply to the use of this function:
The results are undefined if any of these restrictions are not met.
Generic Function
update-dependentSyntax:
update-dependent metaobject dependent &rest initargs
Arguments:
The metaobject argument is a class or generic function metaobject. It is the metaobject being reinitialized or otherwise modified.
The dependent argument is an object. It is the dependent being updated.
The initargs argument is a list of the initialization arguments for the metaobject redefinition.
Values:
The value returned by update-dependent is unspecified.
Purpose:
This generic function is called to update a dependent of metaobject.
When a class or a generic function is reinitialized each of its dependents is updated. The initargs argument to update-dependent is the set of initialization arguments received by reinitialize-instance.
When a method is added to a generic function, each of the generic function's dependents is updated. The initargs argument is a list of two elements: the symbol add-method, and the method that was added.
When a method is removed from a generic function, each of the generic function's dependents is updated. The initargs argument is a list of two elements: the symbol remove-method, and the method that was removed.
In each case, map-dependents is used to call update-dependent on each of the dependents. So, for example, the update of a generic function's dependents when a method is added could be performed by the following code:
(map-dependents generic-function #'(lambda (dep) (update-dependent generic-function dep 'add-method new-method
Methods:
There are no specified methods on this generic function.
Notes:
See the ``Dependent Maintenance Protocol'' section for remarks about the use of this facility.
Generic Function validate-superclass
Syntax:
validate-superclass class superclass
Arguments:
The class argument is a class metaobject.
The superclass argument is a class metaobject.
Values:
This generic function returns true or false.
Purpose:
This generic function is called to determine whether the class superclass is suitable for use as a superclass of class.
This generic function can be be called by the implementation or user code. It is called during class metaobject initialization and reinitialization, before the direct superclasses are stored. If this generic function returns false, the initialization or reinitialization will signal an error.
Methods:
Primary Method validate-superclass (class class) (superclass class)
This method returns true in three situations:
In all other cases, this method returns false.
This method can be overridden.
Notes:
Defining a method on validate-superclass requires detailed knowledge of of the internal protocol followed by each of the two class metaobject classes. A method on validate-superclass which returns true for two different class metaobject classes declares that they are compatible.
Generic Function writer-method-class
Syntax:
writer-method-class class direct-slot &rest initargs
Arguments:
The class argument is a class metaobject.
The direct-slot argument is a direct slot definition metaobject.
The initargs argument is a list of initialization arguments and values.
Values:
The value returned is a class metaobject.
Purpose:
This generic function is called to determine the class of writer methods created during class initialization and reinitialization. The result must be a subclass of standard-writer-method.
The initargs argument must be the same as will be passed to make-instance to create the reader method. The initargs must include :slot-definition with slot-definition as its value.
Methods:
Primary Method writer-method-class (class standard-class) (direct-slot standard-direct-slot-definition) &rest initargs
Primary Method writer-method-class (class funcallable-standard-class) (direct-slot standard-direct-slot-definition) &rest initargs
These methods returns the class standard-writer-method. These methods can be overridden.