Note: A more complete exposition is contained in
I. R. Forman and S. H. Danforth
"Putting Metaclasses to Work"
Addison Wesley Longman (1998).
|
PostScript |
Adobe PDF |
Reflective programming techniques are useful and arise naturally in those forms of Object-Oriented Programming where classes are objects. Within this context, an obvious step is to encapsulate generalized reflective behavior within class frameworks to enable reuse of this behavior through inheritance. But, to accomplish this, it is essential that classes (as objects) respond to all methods responded to by their ancestors. Otherwise, inherited reflective code is not necessarily valid for subclass instances, which can result in method resolution failures. This potential problem has been called metaclass incompatibility. In SOM, we are led inescapably to the conclusion that metaclass declarations for classes must be treated as behavioral constraints, and that subclassing should maintain these constraints. We believe this is the only reasonable approach to preventing metaclass incompatibility and enabling inheritance of reflective code. We believe this approach is further supported by the utility of the computational metaphors it enables. This paper addresses both these points.