CLOS concepts

[Next] [Up] [Previous]
Next: Using CLOS Up: Some CLOS terminology Previous: Some CLOS terminology

CLOS concepts

CLOS is an object-oriented extension to Common Lisp as defined in Common Lisp: The Language, by Guy L. Steele Jr. It is based on generic functions, multiple inheritance, declarative method combination, and a meta-object protocol.

The fundamental objects of CLOS are classes, instances, generic functions, and methods.

A class object determines the structure and behavior of a set of other objects, which are called its instances. Every Common Lisp object is an instance of a class. The class of an object determines the set of operations that can be performed on the object.

A generic function is a function whose behavior depends on the classes or identities of the arguments supplied to it. A generic-function object contains a set of methods, a parameter list (lambda-list), a method combination type, and other information. The methods define the class-specific behavior and operations of the generic function; a method is said to specialize a generic function. When invoked, a generic function executes a subset of its methods based on the classes of its arguments.

A generic function can be used in the same ways that an ordinary function can be used in Common Lisp; in particular, a generic function can be used as an argument to funcall and apply.

A method is an object that contains a method function, a sequence of parameter specializers that specify when the given method is applicable, and a sequence of qualifiers that is used by the method combination facility to distinguish among methods. Each required formal parameter of each method has an associated parameter specializer, and the method will be invoked only on arguments that satisfy its parameter specializers.

TV Raman
Thu Mar 9 20:10:41 EST 1995