Foundations for Virtual Types

Abstract Virtual types have been proposed as a notation for generic programming in object-oriented languages—an alternative to the more familiar mechanism of parametric classes. The trade-offs between the two mechanisms are a matter of current debate: for many examples, both appear to offer convenient (indeed almost interchangeable) solutions; in other situations, one or the other seems to be more satisfactory. However, it has proved difficult to draw rigorous comparisons between the two approaches, partly because current proposals for virtual types vary considerably in their details, and partly because the proposals themselves are described rather informally, usually in the complicating context of full-scale language designs. Work on the foundations of object-oriented languages has already established a clear connection between parametric classes and the polymorphic functions found in familiar typed lambda-calculi. Our aim here is to explore a similar connection between virtual types and dependent records. We present, by means of examples, a straightforward model of objects with embedded type fields in a typed lambda-calculus with subtyping, type operators, fixed points, dependent functions, and dependent records with both bounded and manifest type fields (this combination of features can be viewed as a measure of the inherent complexity of virtual types). Using this model, we then discuss some of the major differences between previous proposals and show why some can be checked statically while others require run-time checks. We also investigate how the partial “duality” of virtual types and parametric classes can be understood in terms of translations between universal and (dependent) existential types.

[1]  Luca Cardelli,et al.  An Extension of System F with Subtyping , 1991, TACS.

[2]  Bjarne Stroustrup,et al.  C++ : programovací jazyk : The C++ programming language (Orig.) , 1997 .

[3]  Thierry Coquand,et al.  The Calculus of Constructions , 1988, Inf. Comput..

[4]  Luca Cardelli,et al.  Typeful Programming , 1989, Formal Description of Programming Concepts.

[5]  Luca Cardelli,et al.  A Semantic Basis for Quest , 1991, J. Funct. Program..

[6]  On the (un)reality of Virtual Types Didier R Emy and J Er^ Ome Vouillon , 1998 .

[7]  Adriana B. Compagnoni,et al.  Decidability of Higher-Order Subtyping with Intersection Types , 1994, CSL.

[8]  Ole Lehrmann Madsen,et al.  Virtual classes: a powerful mechanism in object-oriented programming , 1989, OOPSLA '89.

[9]  Karl Crary,et al.  What is a recursive module? , 1999, PLDI '99.

[10]  J. Y. Girard,et al.  Interpretation fonctionelle et elimination des coupures dans l'aritmetique d'ordre superieur , 1972 .

[11]  Ole Lehrmann Madsen,et al.  Strong typing of object-oriented languages revisited , 1990, OOPSLA/ECOOP '90.

[12]  Martin Odersky,et al.  Making the future safe for the past: adding genericity to the Java programming language , 1998, OOPSLA '98.

[13]  Benjamin C. Pierce,et al.  Higher-Order Subtyping , 1994, Theor. Comput. Sci..

[14]  Luca Cardelli,et al.  On understanding types, data abstraction, and polymorphism , 1985, CSUR.

[15]  Martin Hofmann,et al.  A unifying type-theoretic framework for objects , 1994, Journal of Functional Programming.

[16]  Kresten Krab Thorup Genericity in Java with Virtual Types , 1997, ECOOP.

[17]  Mark Lillibridge,et al.  A type-theoretic approach to higher-order modules with sharing , 1994, POPL '94.

[18]  Gang Chen,et al.  Subtyping Parametric and Dependent Types , 1996 .

[19]  Ole Lehrmann Madsen,et al.  Object-oriented programming in the BETA programming language , 1993 .

[20]  M. Lillibridge Translucent Sums: A Foundation for Higher-Order Module Systems , 1997 .

[21]  Martin Odersky,et al.  Pizza into Java: translating theory into practice , 1997, POPL '97.

[22]  Stephen N. Freund,et al.  Adding type parameterization to the Java language , 1997, OOPSLA '97.

[23]  Ralph Johnson,et al.  design patterns elements of reusable object oriented software , 2019 .

[24]  Andrew C. Myers,et al.  Parameterized types for Java , 1997, POPL '97.

[25]  Luca Cardelli,et al.  Comparing Object Encodings , 1997, TACS.

[26]  Martín Abadi,et al.  A Theory of Objects , 1996, Monographs in Computer Science.

[27]  Kim B. Bruce,et al.  PolyTOIL: A Type-Safe Polymorphic Object-Oriented Language , 1995, ECOOP.

[28]  Kim B. Bruce,et al.  PolyTOIL: A type-safe polymorphic object-oriented language , 1995, TOPL.

[29]  Xavier Leroy,et al.  Manifest types, modules, and separate compilation , 1994, POPL '94.

[30]  Kim B. Bruce,et al.  Semantics-Driven Language Design: Statically Type-safe Virtual Types in Object-oriented Languages , 1999, MFPS.

[31]  Ole Lehrmann Madsen,et al.  Virtual classes: a powerful mechanism in object-oriented programming , 1989, OOPSLA 1989.

[32]  Benjamin C. Pierce,et al.  Bounded quantification is undecidable , 1992, POPL '92.

[33]  John C. Mitchell,et al.  Theoretical aspects of object-oriented programming: types, semantics, and language design , 1994, Choice Reviews Online.

[34]  Ole Lehrmann Madsen,et al.  Strong typing of object-oriented languages revisited , 1990 .

[35]  Robert Cartwright,et al.  Compatible genericity with run-time types for the Java programming language , 1998, OOPSLA '98.

[36]  Martin Odersky,et al.  A Statically Safe Alternative to Virtual Types , 1998, ECOOP.

[37]  Mads Torgersen Virtual types are statically safe , 1998 .

[38]  Ole Lehrmann Madsen,et al.  Virtual Classes - a powerful mechanism in object-oriented programming , 1989 .

[39]  Benjamin C. Pierce,et al.  Simple type-theoretic foundations for object-oriented programming , 1994, Journal of Functional Programming.

[40]  Mads Torgersen,et al.  Unifying Genericity - Combining the Benefits of Virtual Types and Parameterized Classes , 1999, ECOOP.