Previous | Table of Contents | Next |
We distinguish between generic functions, which are interfaces implemented with methods, and functions that are procedural interfaces. The notation arguments are italicized. When there is a list of a variable number of options in the argument list, it is surrounded by {}. When the list can be zero or more, you use *. When the list must be one or more, you use +. The &rest notation is a standard Common Lisp notation that takes arguments following the position in the argument list marked by &rest and makes them into a list bound to the name following the &rest. The &optional notation takes arguments following the position in the argument list marked by &optional, and if they are not present in an actual function call, the argument gets set to a (possibly user-defined) default value.
I dont attempt to handle all cases in this summary. For the complete specification of all CLOS operators, consult the ANSI standard (ANSI, 1996). However, the list given covers most of the common operations. The operations omitted here are used in parts of the MOP (except as used in the examples) and operations having to do with method combinations.
call-next-method &rest arguments (Function)
Returns the return value of the next method. call-next-method is used within the body of a method to call the next method, defined by the method combination type in use. If the next method is missing, then an error is signaled. The default behavior of signaling an error is implemented by the no-next-method generic function, called when the system detects the next method is missing. next-method-p tests to see if the next method exists.
Standard method combination permits use of call-next-method in around methods and primary methods. Operator combination types support call-next-method only in around methods.
call-next-method is normally called with no arguments, implicitly using the arguments of the method being used. Other arguments may be supplied as long as their types would cause the same applicable methods to be run as the types of the original arguments.
change-class instance new-class (Generic function)
Returns the instance. instance is an object and new-class is a class object, both with metaclass standard-class. This changes the class of instance to a new class and calls the generic function update-instance-for-different-class.
class-name class (Generic function)
Returns the name of the class. class must be a class object. class-name supports setf to change the name of the class.
class-of object (Function)
Returns an object that is the class of the object. Every object has a class.
defclass name ({superclass}*) ({slot-spec}*) {class-option}* (Macro)
Returns the class object that is a new class or a redefinition of an existing class. The name of the class and the class object become type specifiers.
The arguments are
name The symbol that is the name of this class. superclass A symbol that is the name of a direct superclass of this class. slot-spec The slot specification for a slot of the new class. slot-spec is either a symbol representing the name of the slot or a list containing the name of the slot followed with zero or more options that further specify the slot. The possible options for slot-spec are
:accessor accessor-name accessor-name is a symbol that names the reader generic function for the slot and (setf accessor-name) becomes the writer generic function for the slot. :reader reader-name is a symbol that names the reader-name reader generic function for the slot. :writer function function-specification is either a symbol or specification a function-specification for writing the value of a slot. If function-specification is a symbol, then the writer generic function is called using normal functional syntax (symbol new-value object), but if the function-specification is a list such as (setfsymbol), then the writer is called with setf syntax: (setf (symbol object) new value). :initarg name name is a symbol, by convention a key word. By including name followed by a value in a call to make-instance, the slot is set to value. :initform form form provides the default initial value for the slot. form evaluates in the lexical environment where defclass is defined. When an initarg is present in a call to make-instance, make-instance uses the value provided by :initarg rather than the value of form specified in :initform. :type type This specifies the type of value of a slot. CLOS semantics do not specify an error if the value stored in the slot is actually of a different type. :allocation allocation-type This determines whether the slot is allocated as a local slot (the default) or as a slot shared among all instances of the class. The default allocation-type is :instance. Shared slots use :class allocation-type.
The possible options for class-option are
(:documentation string) doc-string is a string that should contain doc- documentation for the class. (:default-initargs {initarg-name This option specifies the default values for initargs. Each form is used as an initial form}*) value form for the initarg of initarg-name. This option is the only class option inherited by subclasses. (:metaclass class-name) This specifies the name of the class of the new class. The default metaclass is standard-class.
Previous | Table of Contents | Next |