By hooking the code excerpts from listings 13 and 14 into the skeleton of
listing 12, we have completed our check for the “binary completeness” property.
4 Conclusion
In this paper, we have described why binary methods are a problematic con-
cept in traditional object-oriented languages: the relationship between types and
classes in the context of inheritance, and the need for privileged access to the
internal representation of objects make it difficult to implement.
From the Clos perspective, we have demonstrated that implementing binary
methods is a straightforward process, for at least the following two reasons.
1. The covariance / contravariance problem does not exist, because Clos generic
functions natively support multiple dispatch.
2. When privileged access to internal information is needed, the dynamic na-
ture of Common Lisp provides solutions that are unavailable in statically
typed languages. Besides, the package system is completely orthogonal to
the object-oriented layer and is pretty liberal in what you can access and
how (admittedly, at the expense of breaking modularity just as in other
languages).
From the Mop perspective, it is also important to realize that we have not
just made the concept of binary methods accessible; we have implemented it
directly and explicitly: we have shown ways to not only implement it, but also
enforce a correct usage of it, and even a correct implementation of it. To this
aim, we have actually programmed a new object system which behaves quite
differently from the default Clos. Clos, along with its Mop, is not only an
object system. It is an object system designed to let you program your own
object systems.
References
[Bruce et al., 1995] Bruce, K. B., Cardelli, L., Castagna, G., Eifrig, J., Smith, S. F.,
Trifonov, V., Leavens, G. T., and Pierce, B. C. (1995). On binary methods. Theory
and Practice of Object Systems, 1(3):221–242.
[Castagna, 1995] Castagna, G. (1995). Covariance and contravariance: conflict without
a cause. ACM Transactions on Programming Languages and Systems, 17(3):431–447.
[Keene, 1989] Keene, S. E. (1989). Object-Oriented Programming in Common Lisp: a
Programmer’s Guide to Clos. Addison-Wesley.
[Kiczales et al., 1991] Kiczales, G. J., des Rivi`eres, J., and Bobrow, D. G. (1991). The
Art of the Metaobject Protocol. MIT Press, Cambridge, MA.
[Paepcke, 1993] Paepcke, A. (1993). User-level language crafting – introducing the
Clos metaobject protocol. In Paepcke, A., editor, Object-Oriented Programming:
The CLOS Perspective, chapter 3, pages 65–99. MIT Press. Downloadable version
at http://infolab.stanford.edu/
~
paepcke/shared-documents/mopintro.ps.