next up previous
Next: HyperTalk Up: Programming Language Support Previous: Messages and Active

Generic Functions in CLOS

  The Common Lisp Object System (CLOS) [6] is open in the same way as Smalltalk, but in addition and as an alternative the method combination facility (explained below) provides CLOS with yet another kind of open points.

In CLOS, a generic function can be a combination of several methods. Using standard method combination, a generic function is an aggregation of all applicable before methods, a primary method, and all applicable after methods.gif Relative to a given method combination technique, such as standard method combination, every activation of a generic function may be considered as an open point. If one wants to fill in additional details of a given generic function, it may be done by augmenting the class hierarchy with an applicable method belonging to the generic function.

It is worth noticing that the openness of CLOS is general enough also to cover the active values in Loops, which we described in the previous section. Slots in objects are intended always to be read and written via methods (which typically are generated automatically, but on request). Such accessor methods are in the same way as all other methods subject to method combination during the call of a generic function. Thus, it is possible to achieve the effect of an active value by defining before, after, or around methods in the generic accessor functions. Consequently, both variable reading and writing are open in CLOS.

A CLOS environment is an extension of a Common Lisp environment, and as such it is incremental and workspace-oriented. Thus, CLOS provides for late binding of open points in the same way as Smalltalk does. A generic function acting as the definition behind an open point may be ``multi-bound,'' and the resulting generic function is a declarative combination of the multiple bindings. This is in contrast to Smalltalk and Beta, both of which use imperative combination (using messages to the pseudo variable super and inner respectively). Furthermore, it is worth noticing that a CLOS environment distinguishes between ordinary Lisp functions and generic functions. Only generic functions have the potential to be open in the sense described above. In analogy to our discussion of open points in Smalltalk, it may be attractive only to consider a subset of the generic functions as open points.



next up previous
Next: HyperTalk Up: Programming Language Support Previous: Messages and Active



Kurt Noermark
Wed Mar 6 09:44:24 MET 1996