[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11. CLOS

Generic: add-method generic-function method
Method: add-method {(generic-function standard-generic-function) (method method)}

Macro: call-method {method next-method-list}

Macro: call-next-method {&rest

Generic: change-class instance new-class
Method: change-class {(instance standard-object) (new-class standard-class)}
Method: change-class {(instance t) (new-class symbol)}

Generic: class-name class
Method: class-name {(class class)}

Generic: (setf class-name) new-value class
Method: (setf class-name) {new-value (class class)}

Function: class-of {object}
The function class-of returns the class of which the given object is an instance. The argument to class-of may be any Common-Lisp

Function: compute-applicable-methods {generic-function function-arguments}

Macro: defclass {class-name ({superclass-name}*)} ({slot-specifier}*) [class-option]
 
class-name ::= symbol
superclass-name ::= symbol
slot-specifier ::= slot-name | (slot-name [slot-option])
slot-name ::= symbol
slot-option ::= {:reader reader-function-name}*
        | {:writer writer-function-name}*
        | {:accessor reader-function-name}*
        | {:allocation allocation-type}
        | {:initarg initarg-name}*
        | {:initform form}
        | {:type type-specifier}
        | {:documentation string}
reader-function-name ::= symbol
writer-function-name ::= function-name
function-name ::= symbol |(setf symbol)
initarg-name ::= symbol
allocation-type ::= :instance | :class
class-option ::= (:default-initargs initarg-list)
        | (:documentation string)
        | (:metaclass class-name)
initarg-list ::= {initarg-name default-initial-value-form}*

Macro: defgeneric {function-name lambda-list [option | {method-description}*]}
 
function-name ::= symbol | (setf symbol)
lambda-list ::= ({var}*
        [&optional
        [&rest
        [&key
keyword-parameter ::= var | ( {var | (keywordvar )})
option ::= (:argument-precedence-order {parameter-name}+)
        | (declare {declaration}+)
        | (:documentation string)
        | (:method-combination symbol {arg}*)
        | (:generic-function-class class-name)
        | (:method-class class-name)
method-description ::=
        (:method {method-qualifier}* specialized-lambda-list
         [{declaration}* | documentation]
         {form}*)
method-qualifier ::= non-nil-atom
specialized-lambda-list ::= ({var | (var parameter-specializer-name)}*
        [&optional
        [&rest
        [&key
        [&aux
specialized-keyword-parameter ::= var
        | {({var | (keywordvar)} [initform [supplied-p-parameter]])}*
parameter-specializer-name ::= symbol | (eql eql-specializer-form)

Macro: define-method-combination {name [short-form-option]}
Macro: define-method-combination {name lambda-list ({method-group-specifier}*) [(:arguments . lambda-list)] [(:generic-function generic-fn-symbol)] [{declaration}* | doc-string] {form}*}
 
short-form-option ::= :documentation string 
                        | :identity-with-one-argument boolean 
                        | :operator operator 
method-group-specifier ::= (variable  {qualifier-pattern}+ | predicate
                        [long-form-option])
long-form-option ::= :description format-string 
                        | :order order 
                        | :required boolean

Macro: defmethod {function-name {method-qualifier}+ specialized-lambda-list [{declaration}* | doc-string] {form}*}
 
function-name ::= symbol | (setf symbol)
method-qualifier ::= non-nil-atom 
parameter-specializer-name ::= symbol | (eql eql-specializer-form )

Generic: documentation x &optional
Method: documentation {(method standard-method) &optional
Method: documentation {(generic-function standard-generic-function) &key@c}
Method: documentation {(class standard-class) &optional
Method: doumentation {(method-combination method-combination) &optional
Method: documentation {(slot-description standard-slot-description) &key@c}
Method: documentation {(symbol symbol) &optional
Method: documentation {(list list) &optional

Generic: (setf documentation) new-value x &optional
Method: (setf documentation) {new-value (method standard-method) &optional
Method: (setf documentation) {new-value (class standard-class) &optional
Method: (setf documentation) {new-value (method-combination method-combination)}
Method: (setf documentation) {new-value (slot-description standard-slot-description) &optional
Method: (setf documentation) {new-value (symbol symbol) &optional
Method: (setf documentation) {new-value (list list) &optional

Function: ensure-generic-function {function-name &key
 
function-name ::= symbol | (setf symbol)

Function: find-class {symbol &optional

The function find-class returns the class object named by the given symbol in the given environment. The first argument to find-class is a symbol.

Generic: find-method generic-function method-qualifiers specializers &optional
Method: find-method {(generic-function standard-generic-function)}
method-qualifiers specializers &optional

Generic: function-keywords method
Method: function-keywords {(method standard-method)}

The generic function function-keywords is used to return the keyword parameter specifiers for a given method.

Macro: generic-function {lambda-list \mchoice{option | {method-description}*}}

 
option ::= (:argument-precedence-order {parameter-name}+)
        | (declare {declaration}+)
        | (:documentation string)
        | (:method-combination symbol {arg}*)
        | (:generic-function-class class-name)
        | (:method-class class-name)
method-description ::= (:method {method-qualifier}*
                                specialized-lambda-list
                                {declaration | documentation}*
                                {form}*)
The generic-function macro creates an anonymous generic function. The generic function is created with the set of methods specified by its method descriptions. The option, method-qualifier, and specialized-lambda-list arguments are the same as for defgeneric. The generic function object is returned as the result. If no method descriptions are specified, an anonymous generic function with no methods is created. See defgeneric@c, generic-flet@c, generic-labels@c, defmethod@c.

Generic: initialize-instance instance &rest
Method: initialize-instance {(instance standard-object) &rest

The generic function initialize-instance is called by make-instance to initialize a newly created instance. The generic function initialize-instance is called with the new instance and the defaulted initialization arguments.

Function: invalid-method-error {method format-string &rest

The function invalid-method-error is used to signal an error when there is an applicable method whose qualifiers are not valid for the method combination type. The error message is constructed by using a format string and any arguments to it. Because an implementation may need to add additional contextual information to the error message, invalid-method-error should be called only within the dynamic extent of a method combination function. The function invalid-method-error is called automatically when a method fails to satisfy every qualifier pattern and predicate in a define-method-combination form. A method combination function that imposes additional restrictions should call invalid-method-error explicitly if it encounters a method it cannot accept.

Generic: make-instance class &rest@c initargs
Method: make-instance {(class standard-class) &rest
Method: make-instance {(class symbol) &rest

The generic function make-instance creates and returns a new instance of the given class. The generic function make-instance may be used as described in section 1.9. The class argument is a class object or a symbol that names a class. The remaining arguments form a list of alternating initialization argument names and values. If the second of the above methods is selected, that method invokes make-instance on the arguments (find-class class) and initargs. The initialization arguments are checked within make-instance (see section 1.9). The new instance is returned.

Generic: make-instances-obsolete class
Method: make-instances-obsolete {(class standard-class)}
Method: make-instances-obsolete {(class symbol)}

Function: method-combination-error {format-string &rest

The function method-combination-error is used to signal an error in method combination. The error message is constructed by using a format string and any arguments to it. Because an implementation may need to add additional contextual information to the error message, method-combination-error should be called only within the dynamic extent of a method combination function. The format-string argument is a control string that can be given to format, and args are any arguments required by that string.

Generic: method-qualifiers method
Method: method-qualifiers {(method standard-method)}

The generic function method-qualifiers returns a list of the qualifiers of the given method.

Function: next-method-p {}

The locally defined function next-method-p can be used within the body of a method defined by a method-defining form to determine whether a next method exists.

Generic: no-applicable-method generic-function &rest
Method: no-applicable-method {(generic-function t) &rest

The generic function no-applicable-method is called when a generic function of the class standard-generic-function is invoked and no method on that generic function is applicable. The default method signals an error.

Generic: no-next-method generic-function method &rest
Method: no-next-method {(generic-function standard-generic-function) (method standard-method) &rest

Generic: print-object object stream
Method: print-object {(object standard-object) stream}

The generic function print-object writes the printed representation of an object to a stream. The function print-object is called by the print system; it should not be called by the user.

Generic: reinitialize-instance instance &rest
Method: reinitialize-instance {(instance standard-object) &rest

The generic function reinitialize-instance can be used to change the values of local slots according to initialization arguments. This generic function is called by the Meta-Object Protocol. It can also be called by users.

Generic: remove-method generic-function method
Method: remove-method {(generic-function standard-generic-function) method}

The generic function remove-method removes a method from a generic function. It destructively modifies the specified generic function and returns the modified generic function as its result.

Generic: shared-initialize instance slot-names &rest
Method: shared-initialize {(instance standard-object) slot-names &rest

The generic function shared-initialize is used to fill the slots of an instance using initialization arguments and :initform forms. It is called when an instance is created, when an instance is re-initialized, when an instance is updated to conform to a redefined class, and when an instance is updated to conform to a different class. The generic function shared-initialize is called by the system-supplied primary method for initialize-instance, reinitialize-instance, update-instance-for-redefined-class, and update-instance-for-different-class.

Function: slot-boundp {instance slot-name

The function slot-boundp tests whether a specific slot in an instance is bound. The arguments are the instance and the name of the slot.

Function: slot-exists-p {object slot-name}

The function slot-exists-p tests whether the specified object has a slot of the given name. The object argument is any object. The slot-name argument is a symbol.

Function: slot-makunbound {instance slot-name}

The function slot-makunbound restores a slot in an instance to the unbound state. The arguments to slot-makunbound are the instance and the name of the slot.

Generic: slot-missing class object slot-name operation &optional
Method: slot-missing {(class t) object slot-name operation &optional

The generic function slot-missing is invoked when an attempt is made to access a slot in an object whose metaclass is standard-class and the name of the slot provided is not a name of a slot in that class. The default method signals an error.

Generic: slot-unbound class instance slot-name
Method: slot-unbound {(class t) instance slot-name}

The generic function slot-unbound is called when an unbound slot is read in an instance whose metaclass is standard-class. The default method signals an error.

Function: slot-value {object slot-name}

The function slot-value returns the value contained in the slot slot-name of the given object. If there is no slot with that name, slot-missing is called. If the slot is unbound, slot-unbound is called. The macro setf can be used with slot-value to change the value of a slot.

Generic: update-instance-for-different-class previous current &rest
Method: update-instance-for-different-class {(previous standard-object) (currentstandard-object) &rest

Generic: update-instance-for-redefined-class instance added-slots discarded-slots property-list &rest
Method: update-instance-for-redefined-class {(instance standard-object) added-slots discarded-slots property-list &rest

Macro: with-accessors {({slot-entry}*) instance-form {declaration}* {form}*}

The macro with-accessors creates a lexical environment in which specified slots are lexically available through their accessors as if they were variables. The macro with-accessors invokes the appropriate accessors to access the specified slots. Both setf and setq can be used to set the value of the slot. The result returned is that obtained by executing the forms specified by the body argument.

Macro: with-slots {({slot-entry}*) instance-form {declaration}* {form}*}
 
slot-entry ::= slot-name | (variable-name slot-name)

The macro with-slots creates a lexical context for referring to specified slots as though they were variables. Within such a context the value of the slot can be specified by using its slot name, as if it were a lexically bound variable. Both setf and setq can be used to set the value of the slot.


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by Juan Jose Garcia Ripoll on May, 30 2005 using texi2html