T3 : CLOS - Generic Functions and Metaobject Protocol

Date: Monday, March 31, 2008 (afternoon)

Presenter: Pascal Costanza, Vrije Universiteit Brussel

Level: Advanced

Prerequisites: This tutorial is targeted at researchers and practitioners. A good understanding of class-based OOP is required. Experience with Lisp may be helpful, but is not necessary. The tutorial is specifically targeted at non-Lispers.


The Common Lisp Object System (CLOS) is unique in two ways. 1) In most OOP languages, methods belong to classes and are invoked by sending messages. In CLOS, methods belong to generic functions, which select and execute the correct methods according to the types of the arguments they receive. 2) The CLOS Metaobject Protocol (MOP) specifies how its essential building blocks are implemented in CLOS itself. This allows changing and extending the semantics of CLOS for a well-defined scope.

In this tutorial, you will learn about these powerful concepts, with a focus on the general ideas instead of technical details. I will develop – live during the tutorial - the code for an interpreter for generic functions that performs selection and execution of methods. I will then discuss how that interpreter can be extended to introduce, for example, multimethods and AOP-like advice, and sketch how generic functions are made efficient in actual CLOS implementations. In the second part, I will illustrate the extensibility of CLOS by implementing - live - the Python object model as a metaclass. Other practical extensions based on the CLOS MOP are also sketched.

Metaobject protocols are traditionally used for modularizing crosscutting concerns, and are one of the precursors to AOP. One goal of this tutorial is to present the concepts and strengths of metaobject protocols that are still relevant in this regard in practical and especially industrial settings. You will get the necessary insights as well as pointers to literature and online material to deepen your knowledge.


Pascal Costanza has a Ph.D. degree from the University of Bonn, Germany, and currently works at the Vrije Universiteit Brussel, Belgium. He has been involved in the specification and implementation of the languages Gilgul and Lava, and the design and application of the JMangler framework for load-time transformation of Java classes. He has also implemented aspect-oriented and context-oriented extensions for CLOS that heavily rely on its MOP. He is furthermore the initiator and lead of "Closer", an open source project that provides a compatibility layer for the CLOS MOP across multiple Common Lisp implementations.


Instant Feedback