Unifying Genericity - Combining the Benefits of Virtual Types and Parameterized Classes

  • Authors:
  • Kresten Krab Thorup;Mads Torgersen

  • Affiliations:
  • -;-

  • Venue:
  • ECOOP '99 Proceedings of the 13th European Conference on Object-Oriented Programming
  • Year:
  • 1999

Quantified Score

Hi-index 0.00

Visualization

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 bene fits of both, in particular retaining mutual recursion and covariance of virtual types as well as the function-like nature of parameterized classes.