Common Lisp the Language, 2nd Edition

Next: Error Terminology Up: Common Lisp Object Previous: Common Lisp Object

# 28.1. Programmer Interface Concepts

The Common Lisp Object System (CLOS) is an object-oriented extension to Common Lisp. It is based on generic functions, multiple inheritance, declarative method combination, and a meta-object protocol.

The first two parts of this specification describe the standard Programmer Interface for the Common Lisp Object System. The first part, Programmer Interface Concepts, contains a description of the concepts of the Common Lisp Object System, and the second part, Functions in the Programmer Interface, contains a description of the functions and macros in the Common Lisp Object System Programmer Interface. The third part, The Common Lisp Object System Meta-Object Protocol, explains how the Common Lisp Object System can be customized. [The third part has not yet been approved by X3J13 for inclusion in the forthcoming Common Lisp standard and is not included in this book.-GLS]

The fundamental objects of the Common Lisp Object System 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 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 as an ordinary function in Common Lisp; in particular, a generic function can be used as an argument to `funcall` and `apply` and can be given a global or a local name.

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.

The method combination facility controls the selection of methods, the order in which they are run, and the values that are returned by the generic function. The Common Lisp Object System offers a default method combination type and provides a facility for declaring new types of method combination.

- Error Terminology
- Classes
  - Defining Classes
  - Creating Instances of Classes
  - Slots
  - Accessing Slots
- Inheritance
  - Inheritance of Methods
  - Inheritance of Slots and Slot Options
  - Inheritance of Class Options
  - Examples
- Integrating Types and Classes
- Determining the Class Precedence List
  - Topological Sorting
  - Examples
- Generic Functions and Methods
  - Introduction to Generic Functions
  - Introduction to Methods
  - Agreement on Parameter Specializers and Qualifiers
  - Congruent Lambda-Lists for All Methods of a Generic Function
  - Keyword Arguments in Generic Functions and Methods
- Method Selection and Combination
  - Determining the Effective Method
  - Standard Method Combination
  - Declarative Method Combination
  - Built-in Method Combination Types
- Meta-objects
  - Metaclasses
  - Standard Metaclasses
  - Standard Meta-objects
- Object Creation and Initialization
  - Initialization Arguments
  - Declaring the Validity of Initialization Arguments
  - Defaulting of Initialization Arguments
  - Rules for Initialization Arguments
  - Shared-Initialize
  - Initialize-Instance
  - Definitions of Make-Instance and Initialize-Instance
- Redefining Classes
  - Modifying the Structure of Instances
  - Initializing Newly Added Local Slots
  - Customizing Class Redefinition
  - Extensions
- Changing the Class of an Instance
  - Modifying the Structure of an Instance
  - Initializing Newly Added Local Slots
  - Customizing the Change of Class of an Instance
- Reinitializing an Instance
  - Customizing Reinitialization

Next: Error Terminology Up: Common Lisp Object Previous: Common Lisp Object