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 条
  • [11] First-Class Subtypes
    Yallop, Jeremy
    Dolan, Stephen
    ELECTRONIC PROCEEDINGS IN THEORETICAL COMPUTER SCIENCE, 2019, (294): : 74 - 85
  • [12] First-class whine
    Hendra, T
    FORBES, 1998, : 49 - +
  • [13] First-class synchronization barriers
    Turbak, F
    ACM SIGPLAN NOTICES, 1996, 31 (06) : 157 - 168
  • [14] COMPOSING FIRST-CLASS TRANSACTIONS
    HAINES, N
    KINDRED, D
    MORRISETT, JG
    NETTLES, SM
    WING, JM
    ACM TRANSACTIONS ON PROGRAMMING LANGUAGES AND SYSTEMS, 1994, 16 (06): : 1719 - 1736
  • [15] Contracts for First-Class Classes
    Strickland, T. Stephen
    Felleisen, Matthias
    ACM SIGPLAN NOTICES, 2010, 45 (12) : 97 - 111
  • [16] Measurements As First-class Artifacts
    Laffranchini, Paolo
    Rodrigues, Luis
    Canini, Marco
    Krishnamurthy, Balachander
    IEEE CONFERENCE ON COMPUTER COMMUNICATIONS (IEEE INFOCOM 2019), 2019, : 415 - 423
  • [17] A Case for First-Class Environments
    Tan, Jinhao
    Oliveira, Bruno C. D. S.
    PROCEEDINGS OF THE ACM ON PROGRAMMING LANGUAGES-PACMPL, 2024, 8 (OOPSLA): : 2521 - 2550
  • [18] Creating first-class universities
    不详
    CHINESE EDUCATION AND SOCIETY, 2004, 37 (06): : 27 - 37
  • [19] First-class monadic schedules
    Mirani, R
    Hudak, P
    ACM TRANSACTIONS ON PROGRAMMING LANGUAGES AND SYSTEMS, 2004, 26 (04): : 609 - 651
  • [20] FIRST-CLASS SCIENTIFIC CONTRIBUTION
    Cirgic, Adnan
    LINGUA MONTENEGRINA, 2023, 31 : 377 - 381