Abstract
Generic types in programming languages are most often supported with various forms of parametric polymorphism, i.e. functions on types. Within the framework of object-oriented languages, virtual types present an alternative where specific types are derived from generic ones using inheritance rather than function application. While both mechanisms are statically safe and support basic genericity, they have very different typing properties, each of them providing for the description of useful relationships, which are not expressible with the other. In this paper we present, through the use of examples, a mechanism for describing generic classes: structural virtual types. This mechanism is essentially a merger of parameterized classes and virtual types and includes the benefits of both, in particular retaining mutual recursion and covariance of virtual types as well as the function-like nature of parameterized classes.
★
Currently visiting Professor Akinori Yonezawa at University of Tokyo, Japan.
★★
Currently visiting Luca Cardelli at Microsoft Research, Cambridge, UK.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Similar content being viewed by others
References
ABB+98._Ole Agesen, Gilad Bracha, Kim Bruce, Luca Cardelli, Corky Cartwright, Erik Ernst, Kathleen Fisher, Martin Odersky, Bill Joy, Benjamin Pierce, John Rose, Guy Steele, Jr., David Stoutamire, Kresten Krab Thorup, Mads Torgersen, David Ungar, Philip Wadler, et al. Personal communication. The “Java Genericity” mailing list, 1997–1998.
Ole Agesen, Stephen N. Freund, and John C. Mitchell. Adding type parameterization to the java programming language. In Object Oriented Programming: Systems, Languages and Applications (OOPSLA). ACM, October 1997.
Gilad Bracha, Martin Odersky, David Stoutamire, and Philip Wadler. Making the future safe for the past: Adding genericity to the java programming language. In Chambers [Cha98].
Kim Bruce, Martin Odersky, and Philip Wadler. A statically safe alternative to virtual types. In European Conference on Object-Oriented Programming (ECOOP), 1998.
Kim Bruce. Subtyping is not a good match for object-oriented programming languages. In Mehmet Aksit and Satoshi Matsouka, editors, European Conference on Object-Oriented Programming (ECOOP), number 1241 in LNCS, Jyväskylä, Finland, 1997. AiTO, Springer Verlag.
Peter Canning, William Cook, Walt Hill, Walter Olthoff, and John Mitchell.F-bounded qualification for object-oriented programming. In ACM Conference on Functional Programming and Computer Architecture. ACM Press, 1989.
Craig Chambers, editor. Object Oriented Programming: Systems, Languages and Applications (OOPSLA), Vancouver, BC, October 1998. SIGPLAN, ACM Press.
William Cook. A proposal for making Eiffel type-safe. In Stephen Cook, editor, European Conference on Object-Oriented Programming (ECOOP), pages 57–70, Nottingham, July 1989. AiTO, Nottingham University Press.
Robert Cartwright and Guy L. Steele. Compatible genericity with runtime-types for the Java programming language. In Chambers [Cha98].
Margaret A. Ellis and Bjarne Stroustrup. The Annotated C++ Reference Manual. Addison-Wesley, 1990.
Atsushi Igarashi and Benjamin C. Pierce. Foundations for virtual types. In Rachid Guerraoui, editor, European Conference on Object-Oriented Programming (ECOOP), LNCS, Lisbon, Portugal, 1999. AiTO, Springer Verlag.
Niel D. Jones, editor. Conf. Proceedings of the 24th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL), Paris, January 1997. ACM Press.
Bent Bruun Kristensen, Ole Lehrmann Madsen, Birger Møller-Pedersen, and Kristen Nygaard. Abstraction mechanisms in the Beta programming language. In Conf. Proceedings of the 10th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL), Austin, TX, 1983.
Barbara Liskov, Alan Snyder, Russel Atkinson, and Craig Schaffert. Abstraction mechanisms in CLU. Communications of the ACM, 20(8), August 1977.
Boris Magnusson. Code reuse considered harmful. JOOP Journal of Object-Oriented Programming, 4(3), November 1991.
Andrew Myers, Joseph Bank, and Barbara Liskov. Parameterized types for Java. In Jones [Jon97].
Bertrand Meyer. Genericity versus inheritance. In Object Oriented Programming: Systems, Languages and Applications (OOPSLA), pages 391–405, 1986.
Mjølner Informatics, ApS, Aarhus. The Mjølner System BETA Compiler Reference Manual, 1997. MIA 90-02(1.6), http://www.mjolner.dk.
Ole Lehrmann Madsen and Birger Møller-Pedersen. Virtual classes: A powerful mechanism in object-oriented programming. In Object Oriented Programming: Systems, Languages and Applications (OOPSLA). SIGPLAN, ACM Press, 1989.
Ole Lehrmann Madsen, Birger Møller-Pedersen, and Kristen Nygaard. Object-Oriented Programming in the BETA Programming Language. Addison-Wesley, 1993.
Gail C. Murphy and David Notkin. The interaction between static typing and frameworks. Technical Report TR-93-09-02, University of Washington, 1993.
Gail C. Murphy and David Notkin. On the use of static typing to support operations on frameworks. Object Oriented Systems, 3(4):197–213, December 1996.
Steven Omohundro. The Sather programming language. Dr. Dobb’s Journal, 18(11), October 1993.
Martin Odersky and Philip Wadler. Pizza into Java: Translating theory into practice. In Jones [Jon97].
David Shang. Subtypes and convertible types. Object Currents, 1(6), June 1996.
David Shang. Transframe: The Annotated Reference. Software Systems Research Laboratory, Motorola, Inc., Shamburg, IL, November 1996. http://www.transframe.com.
Kresten Krab Thorup. Genericity in Java with virtual types. In Mehmet Akşit and Satoshi Matsouka, editors, European Conference on Object-Oriented Programming (ECOOP), number 1241 in LNCS, pages 444–471, Jyväskylä, Finland, 1997. AiTO, Springer Verlag.
Mads Torgersen. Virtual types are statically safe. In Kim Bruce, editor, 5th Workshop on Foundations of Object-Oriented Languages, San Diego, CA, January 1998.
Kresten Krab Thorup and Mads Torgersen. Structured virtual types. Informal session on types for Java, 5thWorkshop on Foundations of Object-Oriented Languages, January 1998.
Kresten Krab Thorup and Mads Torgersen. The Idea programming language. Technical report, Department of Computer Science, University of Aarhus, 1999. (To appear).
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 1999 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Krab Thorup, K., Torgersen, M. (1999). Unifying Genericity. In: Guerraoui, R. (eds) ECOOP’ 99 — Object-Oriented Programming. ECOOP 1999. Lecture Notes in Computer Science, vol 1628. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-48743-3_9
Download citation
DOI: https://doi.org/10.1007/3-540-48743-3_9
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-66156-6
Online ISBN: 978-3-540-48743-2
eBook Packages: Springer Book Archive