: Sunday Afternoon Tutorials (13:30 - 17:00) : Languages and Paradigms : Sunday
The Common Lisp Object System: Generic Functions and Metaobject Protocol
Pacific Salon 7
Sunday, 13:30, half day
Pascal Costanza, Vrije Universiteit Brussel
Tutorial number: 13
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, and they select and execute the correct method according to the types of the arguments they receive. 2) The CLOS Metaobject Protocol (MOP) specifies how its essential building blocks are to be implemented in CLOS itself. This allows extending its object model with metaclasses that change important aspects of CLOS for a well-defined scope.
This tutorial introduces these two notions. 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 code can be extended to introduce, for example, multimethods and AOP-like advices, and sketch how generic functions are implemented efficiently in the "real" world. In the second part, I will illustrate the extensibility of the CLOS MOP by implementing—live—the (hashtable-based) Python object model as a metaclass. Other practical extensions based on the CLOS MOP are also sketched, like object-relational mappings, interfaces to foreign-language objects, and domain-specific annotations in classes.
Advanced: A good understanding of class-based OOP. Experience with may be helpful, but the tutorial is specifically targeted at non-Lispers.
Pascal Costanza, Vrije Universiteit Brussel: Pascal Costanza has a Ph. D. degree from the University of Bonn, Germany. His past involvements include specification and implementation of the languages Gilgul and Lava, and the design and application of the JMangler framework for load-time transformation of Java class files. He has also implemented aspect-oriented extensions for CLOS that heavily rely on its MOP, and currently explores possibilities for making object-oriented programs better adaptable to the context of their use. 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.