The Art of the Metaobject Protocol

submited by
Style Pass
2024-09-25 23:00:04

ISBN: 0262610744 Publisher: The MIT PRess Pages: 345

The basic idea of a metaobject protocol is to implement an object system using its own constructs as building blocks. The fundamental constructs available to application programmers, such as classes, generic functions and methods, are themselves instances of (meta)classes. While the resulting design is remarkably consistent and clean, the big win is that a metaobject provides an extremely powerful extension mechanism. The metaobject protocol behaves like an interface towards the language itself, available for the programmer to incrementally customize. Just as we can specialize and extend the behavior of the classes we define in our own applications, we can now extend the language itself using the very same mechanisms. It's a design resulting from the direct conclusion that no language will be universally appropriate for all problems. Instead of fighting the language, the programmer adapts and evolves it to the problem at hand. The Art of the Metaobject Protocol (AMOP) is a wonderful book to learn about these topics.

A metaobject protocol gives application programmers an interesting context. With a metaobject protocol the available design space isn't fixed. Rather the possible design space extends to a larger region. This region is defined by the extension points in the metaobject protocol. To give an example, say we want to change some aspect of object allocation. Or perhaps we want to change the dispatch rules for a set of types. The practical purpose could be to balance the classical trade-off between speed and memory or, more radically, provide a completely different storage mechanism for our objects (e.g. in a distributed key value store). With a metaobject protocol, such fundamental changes to the language are only a few specializations away. The beauty is that we implement it using the very same mechanisms we'd use for traditional object-oriented programming with CLOS. As such, AMOP presents an approach to language design that is radically different from what we've come to know in popular object-oriented languages of today.

Leave a Comment