A first-class approach to genericity

被引:12
|
作者
Allen, E [1 ]
Bannet, J [1 ]
Cartwright, R [1 ]
机构
[1] Rice Univ, Houston, TX 77005 USA
关键词
design; languages;
D O I
10.1145/949343.949316
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
This paper describes how to add first-class generic types including mixins - to strongly-typed 00 languages with nominal subtyping such as Java and C#. A generic type system is "first-class" if generic types can appear in any context where conventional types can appear. In this context, a mixin is simply a generic class that extends one of its type parameters, e.g., a class C<T> that extends T. Although mixins of this form are widely used in C++ (via templates), they are clumsy and error-prone because C++ treats mixins as macros, forcing each mixin instantiation to be separately compiled and type-checked. The abstraction embodied in a mixin is never separately analyzed. Our formulation of mixins using first-class genericity accommodates sound local (class-by-class) type checking. A mixin can be fully type-checked given symbol tables for each of the classes that it directly references-the same context in which Java performs incremental class compilation. To our knowledge, no previous formal analysis of first-class genericity in languages with nominal type systems has been conducted, which is surprising because nominal subtyping has become predominant in mainstream object-oriented programming languages. What makes our treatment of first-class genericity particularly interesting and important is the fact that it can be added to the existing Java language without any change to the underlying Java Virtual Machine. Moreover, the extension is backward compatible with legacy Java source and class files. Although our discussion of a, practical implementation strategy focuses on Java, the same implementation techniques could be applied to other object-oriented languages such as C# or Eiffel that support incremental compilation, dynamic class loading, and nominal subtyping.
引用
收藏
页码:96 / 114
页数:19
相关论文
共 50 条
  • [21] First-Class Dynamic Types
    Homer, Michael
    Jones, Timothy
    Noble, James
    PROCEEDINGS OF THE 15TH ACM SIGPLAN INTERNATIONAL SYMPOSIUM ON DYNAMIC LANGUAGES (DLS '19), 2019, : 1 - 14
  • [22] The lure of first-class science
    不详
    SCIENCE, 2002, 297 (5586) : 1472 - 1472
  • [23] Becoming a First-Class Noticer
    Bazerman, Max H.
    HARVARD BUSINESS REVIEW, 2014, 92 (7-8) : 116 - 119
  • [24] First-class contexts in ML
    Hashimoto, H
    ADVANCES IN COMPUTING SCIENCE-ASIAN' 98, 1998, 1538 : 206 - 223
  • [25] First-Class Citizens All
    Scherer, Marge
    EDUCATIONAL LEADERSHIP, 2013, 71 (02) : 7 - 7
  • [26] Contracts for First-Class Classes
    Strickland, T. Stephen
    Dimoulas, Christos
    Takikawa, Asumu
    Felleisen, Matthias
    ACM TRANSACTIONS ON PROGRAMMING LANGUAGES AND SYSTEMS, 2013, 35 (03):
  • [27] Associations as First-class Elements
    Bildhauer, Daniel
    DATABASES AND INFORMATION SYSTEMS VI: SELECTED PAPERS FROM THE NINTH INTERNATIONAL BALTIC CONFERENCE (DB&IS 2010), 2011, 224 : 108 - 121
  • [28] An experiment in first-class protein
    Mann, HCC
    Hopkins, FG
    LANCET, 1935, 1 : 145 - 147
  • [29] Contracts for First-Class Modules
    Strickland, T. Stephen
    Felleisen, Matthias
    ACM SIGPLAN NOTICES, 2009, 44 (12) : 27 - 38
  • [30] First-Class Object Sets
    Ernst, Erik
    TYPES FOR PROOFS AND PROGRAMS, 2009, 5497 : 83 - 99