Unifying Genericity - Combining the Benefits of Virtual Types and Parameterized Classes
Unifying Genericity - Combining the Benefits of Virtual Types and Parameterized Classes
复制标题
统一通用性 - 结合虚拟类型和参数化类的优点
DOI:
10.1007/3-540-48743-3_9
复制
发表时间:
1999
期刊:
影响因子:
--
通讯作者:
Mads Torgersen
中科院分区:
文献类型:
--
作者:
Kresten Krab Thorup;Mads Torgersen
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.