Next: , Previous: Calling Convention, Up: Top

3 Discriminating Functions

The Common Lisp Object System specifies a great deal of run-time customizeability, such as class redefinition, generic function and method redefinition, addition and removal of methods and redefinitions of method combinations. The additional flexibility defined by the Metaobject Protocol, specifying the generic functions called to achieve the effects of CLOS operations (and allowing many of them to be overridden by the user) makes any form of optimization seem intractable. And yet such optimization is necessary to achieve reasonable performance: the MOP specifies that a slot access looks up the class of the object, and the slot definition from that class and the slot name, and then invokes a generic function specialized on those three arguments. This is clearly going to act against the user's intuition that a slot access given an instance should be relatively fast.

The optimizations performed cannot be done wholly at compile-time, however, thanks to all of these possibilities for run-time redefinition and extensibility. This section describes the optimizations performed in SBCL's CLOS implementation in computing and calling the effective method for generic functions.