This paper takes polymorphism to the multi-object level. Traditional inheritance, polymorphism, and late binding interact nicely to provide both flexibility and safety — when a method is invoked on an object via a polymorphic reference, late binding ensures that we get the appropriate implementation of that method for the actual object. We are granted the flexibility of using different kinds of objects and different method implementations, and we are guaranteed the safety of the combination. Nested classes, polymorphism, and late binding of nested classes interact similarly to provide both safety and flexibility at the level of multi-object systems. We are granted the flexibility of using different families of kinds of objects, and we are guaranteed the safety of the combination. This paper highlights the inability of traditional polymorphism to handle multiple objects, and presents family polymorphism as a way to overcome this problem. Family polymorphism has been implemented in the programming language gbeta, a generalized version of Beta, and the source code of this implementation is available under GPL.1
KeywordsType System Class Family Type Check Virtual Attribute Late Binding
Unable to display preview. Download preview PDF.
- 1.M. Aksit, K. Wakita, J. Bosch, and L. Bergmans. Abstracting object interactions using composition filters. Lecture Notes in Computer Science, 791:152++, 1994. 325Google Scholar
- 2.Ken Arnold and James Gosling. The Java™ Programming Language. The Java™ Series. Addison-Wesley, Reading, MA, USA, 1998.Google Scholar
- 3.L. Augustsson. Cayenne–a language with dependent types. In Proceedings of the 3rd ACM SIGPLAN International Conference on Functional Programming, pages 239–250, 1998.Google Scholar
- 4.Don Batory, Rich Cardone, and Yannis Smaragdakis. Object-oriented frameworks and product lines. In P. Donohoe, editor, Proceedings of the First Software Product Line Conference, pages 227–247, August 2000.Google Scholar
- 5.B. Bobrow, D. DeMichiel, R. Gabriel, S. Keene, G. Kiczales, and D. Moon. Common Lisp Object System Specification. Document 88-002R. X3J13, June 1988.Google Scholar
- 6.Gilad Bracha, Martin Odersky, David Stoutamire, and Philip Wadler. Making the future safe for the past: Adding genericity to the Java programming language. In Craig Chambers, editor, Proceedings OOPSLA’98, ACM SIGPLAN Notices, volume 33, 10, pages 183–200, Vancouver, BC, October 1998.Google Scholar
- 7.K. Bruce, M. Odersky, and P. Wadler. A statically safe alternative to virtual types. Lecture Notes in Computer Science, 1445:523–549, 1998.Google Scholar
- 8.Peter Canning, William Cook, Walter Hill, John Mitchell, and Walter Olthoff. F-bounded polymorphism for object-oriented programming. In Fourth International Conference on Functional Programming and Computer Architecture. ACM, September 1989. Also technical report STL-89-5, from Software Technology Laboratory, Hewlett-Packard Laboratories.Google Scholar
- 9.Robert Cartwright. Compatible genericity with run-time types for the Javatm programming language. In Craig Chambers, editor, Proceedings OOPSLA’98, ACM SIGPLAN Notices, volume 33, 10, Vancouver, October 1998. ACM Press.Google Scholar
- 10.Craig Chambers. Object-oriented multi-methods in Cecil. In O. LehrmannMadsen, editor, Proceedings ECOOP’92, LNCS 615, pages 33–56, Utrecht, The Netherlands, June 1992. Springer-Verlag.Google Scholar
- 11.Craig Chambers. The Cecil Language, Specification and Rationale. Dept. of Comp.Sci. and Eng., Univ. of Washington, Seattle, Washington, 1997.Google Scholar
- 12.Krzysztof Czarnecki and Ulrich Eisenecker. Generative Programming: Methods, Tools, and Applications. Addison-Wesley, 1st edition, 2000.Google Scholar
- 13.Erik Ernst. gbeta–A Language with Virtual Attributes, Block Structure, and Propagating, Dynamic Inheritance. PhD thesis, Devise, Department of Computer Science, University of Aarhus, Aarhus, Denmark, June 1999.Google Scholar
- 14.Gregor Kiczales, John Lamping, Anurag Mendhekar, Chris Maeda, Cristina Lopes, Jean-Marc Loingtier, and John Irwin. Aspect-oriented programming. In Mehmet Aksit and Satoshi Matsuoka, editors, Proceedings ECOOP’97, LNCS 1241, pages 220–242, Jyväskylä, Finland, 9–13 June 1997. Springer.Google Scholar
- 15.Vassily Litvinov. Constraint-based polymorphism in Cecil: Towards a practical and static type system. In Craig Chambers, editor, Proceedings OOPSLA’98, ACM SIGPLAN Notices, volume 33, 10, Vancouver, October 1998. ACM Press.Google Scholar
- 16.D. MacQueen. Modules for standard ML. In Proceedings of the 1984 ACM Symposium on Lisp and Functional Programming, pages 198–207, New York, August 1984. ACM Press.Google Scholar
- 17.Ole Lehrmann Madsen. Semantic analysis of virtual classes and nested classes. In Linda M. Northrop, editor, Proceedings OOPSLA’99, ACM SIGPLAN Notices, volume 34, 10, Denver, October 1999. ACM Press.Google Scholar
- 19.Ole Lehrmann Madsen, Birger Møller-Pedersen, and Kristen Nygaard. Object-Oriented Programming in the BETA Programming Language. Addison-Wesley, Reading, MA, USA, 1993.Google Scholar
- 20.R. Milner, M. Tofte, R. W. Harper, and D. MacQueen. The Definition of Standard ML. MIT Press, 1997.Google Scholar
- 21.Martin Odersky and Philip Wadler. Pizza into Java: Translating theory into practice. In Conference Record of POPL’ 97: The 24th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 146–159, Paris, France, 15-17 January 1997.Google Scholar
- 22.Didier Rémy and Jérôme Vouillon. On the (un)reality of virtual types. Work in progress, available from http://pauillac.inria.fr/~remy/, 2001.
- 23.Andrew Shalit. The Dylan Reference Manual: The Definitive Guide to the New Object-Oriented Dynamic Language. Addison-Wesley, Reading, Mass., 1997.Google Scholar
- 24.Jose H. Solorzano and Suad Alagić. Parametric polymorphism for Javatm: A. In Craig Chambers, editor, Proceedings OOPSLA’98, ACM SIGPLAN Notices, volume 33, 10, Vancouver, October 1998. ACM Press.Google Scholar
- 25.Bjarne Stroustrup. The C++ Programming Language. Addison-Wesley, 3rd edition, 1997.Google Scholar
- 26.Peri Tarr, Harold Ossher, William Harrison, and Stanley M. Sutton. N degrees of separation: Multi-dimensional separation of concerns. In Proceedings of the 1999 International Conference on Software Engineering (ICSE’99), pages 107–119, Los Angeles, May 1999. Association for Computing Machinery.Google Scholar
- 27.Kresten Krab Thorup. Genericity in Java with virtual types. In Proceedings ECOOP’97, LNCS 1241, pages 444–471, Jyväskylä, June 1997. Springer-Verlag.Google Scholar
- 28.Mads Torgersen. Virtual types are statically safe. In 5th Workshop on Foundations of Object-Oriented Languages (FOOL), at http://pauillac.inria.fr/~remy/fool/program.html, January 1998.
- 29.Mjølner Informatics, Århus, Denmark: http://www.mjolner.dk/.
- 30.Pierre Weis, María-Virginia Aponte, Alain Laville, Michel Mauny, and Ascánder Suárez. The CAML reference manual, Version 2.6. Technical report, Projet Formel, INRIA-ENS, 1989.Google Scholar
- 31.Hongwei Xi. Dependent Types in Practical Programming. PhD thesis, Department of Mathematical Sciences, Carnegie Mellon University, Pittsburgh, PA 15213, September 1998.Google Scholar