| | oopsla'05 tutorial on generic functions and the clos metaobject protocol. |
| coordinates.
abstract. The Common Lisp Object System (CLOS) is unique in two ways.- In most OOP languages, methods belong to classes and are invoked by sending messages. In CLOS, methods belong to generic functions instead of classes, and those generic functions select and execute the correct method according to the types of the arguments they receive.
- 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-style 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.
level. Advanced.
attendee background. A good understanding of class-based OOP is required. Experience with Lisp may be helpful, but the tutorial is specifically targeted at non-Lispers.
tutorial objectives. The audience will learn about the basic concepts of generic functions and metaobject protocols. They will get the necessary insights and pointers to existing literature and online material to deepen their knowledge. The focus of the tutorial is not on technical details but on the general ideas.
presentation format. The introductory material, like a short historical perspective and the notion of using class inheritance to model metaclass relationships, will be presented using Keynote slides. The gist of the presentation will consist of implementing an interpreter for generic function dispatch in the first half of the tutorial, and the Python object model example in the second half. The code for these implementations will be developed live with virtually no code prepared upfront. This allows me to react to questions or suggestions by the audience. As a very minor example, this allows me to name certain elementary concepts on the fly according to the audience background, say, what is called fields in some languages is called slots in others, and so on. In my experience, this helps the audience to focus on the essential ideas.
status. The tutorial covers material for which significant validation exists. CLOS and its generic-function-centric approach has been standardized by ANSI and is successfully used in industrial settings. The CLOS Metaobject Protocol is described and specified in the book The Art of the Metaobject Protocol by Gregor Kiczales, Jim des Rivieres and Daniel Bobrow. An introductory paper by Andreas Paepcke, User-Level Language Crafting, describes the basic approach of using the CLOS MOP for integrating object-relational mappings. Generic functions have been incorporated in other languages, like Dylan or MultiJava. CLOS-style metaobject protocols also exist for various languages, including C++, Java and Python.
|
|