Est. 1988 Advanced

CLOS

The Common Lisp Object System — a powerful, standardized object system featuring generic functions, multiple dispatch, multiple inheritance, and the Metaobject Protocol

Created by Daniel G. Bobrow, Linda G. DeMichiel, Richard P. Gabriel, Sonya E. Keene, Gregor Kiczales, David A. Moon

Paradigm Object-Oriented, Reflective
Typing Dynamic, Strong
First Appeared 1988
Latest Version ANSI X3.226-1994 (R2004)

The Common Lisp Object System (CLOS) is the standard object-oriented programming facility defined as part of ANSI Common Lisp. Rather than being a standalone language, CLOS is an integral component of the Common Lisp standard, providing one of the most powerful and flexible object systems ever designed. It introduced concepts — particularly generic functions with multiple dispatch and the Metaobject Protocol — that remain influential in programming language design decades after its specification.

History and Origins

CLOS emerged from the effort to standardize Common Lisp in the mid-1980s. By that time, several incompatible object systems had been developed for various Lisp dialects. The two most prominent were Flavors, developed by Howard Cannon and David Moon at MIT for the Lisp Machine, and CommonLoops, created at Xerox PARC by Daniel Bobrow, Gregor Kiczales, and colleagues.

Flavors, first released around 1979, introduced multiple inheritance and mixins to Lisp programming but used a message-passing model similar to Smalltalk. Its successor, New Flavors, developed at Symbolics in the mid-1980s, moved toward generic functions. Meanwhile, CommonLoops at Xerox PARC explored generic functions, multimethods, and meta-objects in the context of Common Lisp.

When the ANSI X3J13 committee was formed in 1986 to standardize Common Lisp, a subcommittee was tasked with creating a unified object system. The resulting specification — authored by Daniel G. Bobrow, Linda G. DeMichiel, Richard P. Gabriel, Sonya E. Keene, Gregor Kiczales, and David A. Moon — was described as “a marriage of CommonLoops and New Flavors.” The CLOS specification was formally accepted by X3J13 in June 1988 and published in SIGPLAN Notices that September.

CLOS was incorporated into the ANSI Common Lisp standard (ANSI X3.226-1994), making it an inseparable part of every conforming Common Lisp implementation.

Design Philosophy

CLOS takes a fundamentally different approach to object-oriented programming than most mainstream OOP languages. Its core design decisions reflect the Lisp tradition of flexibility, dynamism, and metaprogramming.

Generic Functions over Message Passing

Where languages like Smalltalk, C++, and Java use message passing — an object receives a message and decides how to handle it — CLOS centers on generic functions. A generic function is a function whose behavior depends on the classes of its arguments. Methods do not “belong to” classes; instead, they are attached to generic functions and specialize on argument types. This separation of operations from data types is a deliberate and distinctive design choice.

Multiple Dispatch

Most object-oriented languages dispatch method calls based solely on the type of the receiver (single dispatch). CLOS supports multiple dispatch, where the method selected can depend on the classes of any combination of arguments. This eliminates the need for patterns like the Visitor pattern, which exist in single-dispatch languages to work around this limitation.

Dynamic Redefinition

CLOS is fully dynamic. Classes can be redefined at runtime, and existing instances are lazily updated to reflect the new definition. The CHANGE-CLASS function allows an object to change its class entirely, with a well-defined protocol (UPDATE-INSTANCE-FOR-DIFFERENT-CLASS) for managing the transition. Methods can be added, removed, or redefined while the program is running.

Key Features

Classes and Slots

Classes are defined with DEFCLASS, specifying slots (similar to fields or member variables), superclasses, and various slot options including type constraints, default values, and accessor generation:

1
2
3
4
5
6
(defclass person ()
  ((name :initarg :name
         :accessor person-name)
   (age  :initarg :age
         :accessor person-age
         :initform 0)))

Generic Functions and Methods

Generic functions are declared with DEFGENERIC and specialized methods are defined with DEFMETHOD:

1
2
3
4
5
(defgeneric greet (entity)
  (:documentation "Produce a greeting for an entity."))

(defmethod greet ((p person))
  (format nil "Hello, ~A!" (person-name p)))

Multiple Inheritance

CLOS supports multiple inheritance with a deterministic class precedence list algorithm that linearizes the inheritance graph:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
(defclass student (person)
  ((university :initarg :university
               :accessor student-university)))

(defclass employee (person)
  ((company :initarg :company
            :accessor employee-company)))

(defclass working-student (student employee)
  ())

Method Combinations

The standard method combination supports primary, :before, :after, and :around methods, providing a declarative way to compose behavior across the inheritance hierarchy:

1
2
3
4
5
6
7
8
9
(defmethod greet :before ((s student))
  (format t "~&[Preparing student greeting]"))

(defmethod greet :after ((s student))
  (format t "~&[Student greeting complete]"))

(defmethod greet :around ((s student))
  (format t "~&[Wrapping greeting]~%")
  (call-next-method))

Custom method combinations can also be defined, allowing operators like +, append, or progn to combine method results.

The Metaobject Protocol (MOP)

The Metaobject Protocol is perhaps CLOS’s most conceptually ambitious feature. In CLOS, classes, generic functions, methods, and slot definitions are themselves objects — instances of metaclasses. The MOP allows programmers to customize the behavior of the object system itself by specializing methods on these meta-level objects.

The MOP was described in detail in the influential 1991 book The Art of the Metaobject Protocol by Gregor Kiczales, Jim des Rivières, and Daniel Bobrow. While the MOP was not included in the ANSI standard, it has become a de facto standard implemented by all major Common Lisp systems. The closer-mop compatibility library provides a portable interface across implementations.

Evolution

CLOS has remained remarkably stable since its 1988 specification. The ANSI standard, published in 1994, codified the programmer interface without major changes from the original specification. This stability is by design — CLOS was intended to be extensible through the MOP rather than through changes to the core specification.

The Metaobject Protocol, while never formally standardized, has been widely implemented and has become essential to practical CLOS programming. Libraries like closer-mop bridge minor differences between implementations, and the MOP is used extensively by frameworks for persistence, serialization, validation, and GUI construction.

Gregor Kiczales’s Tiny CLOS (1992), a compact Scheme implementation of CLOS and MOP concepts, served as both a pedagogical tool and a seed for object systems in other Lisp dialects.

Influence

CLOS has had a significant influence on programming language design:

  • Dylan (Apple, early 1990s) derived its object system directly from CLOS, with multiple dispatch as a core feature, but simplified for static compilation.
  • EuLisp adapted CLOS concepts for its object system.
  • GOOPS (GNU Guile) and Swindle (Racket) brought CLOS-style object-oriented programming to Scheme implementations.
  • Gregor Kiczales’s work on the Metaobject Protocol led directly to his later development of Aspect-Oriented Programming and the AspectJ framework.
  • The R language’s S4 class system draws on ideas from CLOS, including generic functions and formal class definitions.

Current Relevance

CLOS remains fully alive as part of every conforming Common Lisp implementation. Major actively maintained implementations include:

  • SBCL (Steel Bank Common Lisp) — high-performance open-source native compiler with monthly releases
  • CCL (Clozure CL) — open-source implementation with full MOP support
  • Allegro CL (Franz Inc.) — commercial implementation used in enterprise applications
  • LispWorks — commercial implementation with comprehensive GUI and MOP support
  • ECL (Embeddable Common Lisp) — designed for embedding in C applications
  • ABCL (Armed Bear Common Lisp) — runs on the JVM
  • CLASP — Common Lisp implementation targeting LLVM, reportedly in continued development

The Common Lisp ecosystem continues to use CLOS as the foundation for libraries spanning persistence (e.g., cl-store), web frameworks, GUI toolkits, and application modeling.

Why It Matters

CLOS demonstrated that object-oriented programming need not be limited to single dispatch and message passing. Its generic functions, multiple dispatch, method combinations, and Metaobject Protocol offered a vision of OOP that was more flexible and more principled than the mainstream model — one where the object system itself is an open, extensible program. While mainstream languages have largely followed the Simula/Smalltalk lineage, CLOS remains a powerful example of what object-oriented programming can look like when designed with the full power of Lisp behind it.

Timeline

1979
Howard Cannon develops the Flavors object system at MIT for the Lisp Machine, introducing multiple inheritance and mixins to Lisp
1986
CommonLoops paper presented at OOPSLA '86 by Bobrow, Kahn, Kiczales, Masinter, Stefik, and Zdybel at Xerox PARC
1986
X3J13 committee formed for ANSI Common Lisp standardization; work on CLOS begins, merging ideas from CommonLoops and New Flavors
1988
CLOS specification (X3J13 Document 88-002R) formally accepted by X3J13 in June, authored by Bobrow, DeMichiel, Gabriel, Keene, Kiczales, and Moon
1988
CLOS specification published in SIGPLAN Notices, Vol. 23, September 1988
1989
Sonya Keene publishes 'Object-Oriented Programming in Common LISP: A Programmer's Guide to CLOS' (Addison-Wesley)
1991
Kiczales, des Rivières, and Bobrow publish 'The Art of the Metaobject Protocol' (MIT Press), the definitive work on the CLOS MOP
1992
Gregor Kiczales creates Tiny CLOS, a pedagogical Scheme implementation of core CLOS and MOP concepts
1994
ANSI X3.226-1994 published, standardizing Common Lisp with CLOS as an integral part — reportedly the first ANSI-standardized object-oriented language

Notable Uses & Legacy

AI and Expert Systems

CLOS has been used extensively in AI research and expert system development, including rule-based systems and knowledge representation frameworks built on top of its flexible object model.

ICAD Knowledge-Based Engineering

The ICAD system, a knowledge-based engineering environment for parametric design in aerospace and manufacturing, was built using Common Lisp with heavy use of CLOS for its object model.

Commercial Lisp Environments

Both Franz Inc.'s Allegro CL and LispWorks use CLOS extensively for their development environments, including GUI frameworks (CLIM, CAPI) and IDE tooling.

Lisp Web Frameworks and Applications

Common Lisp web applications and frameworks leverage CLOS for model definitions, request handling, and middleware — including projects built on frameworks like Hunchentoot and Caveman2.

Language Influence

Influenced By

Flavors New Flavors CommonLoops Smalltalk

Influenced

Dylan EuLisp GOOPS Tiny CLOS Swindle

Running Today

Run examples using the official Docker image:

docker pull clfoundation/sbcl:latest

Example usage:

docker run --rm -v $(pwd):/app -w /app clfoundation/sbcl:latest sbcl --script hello.lisp
Last updated: