Associated types and constraint propagation for mainstream object-oriented generics

被引:7
|
作者
Järvi, J
Willcock, J
Lumsdaine, A
机构
[1] Texas A&M Univ, College Stn, TX 77843 USA
[2] Indiana Univ, Open Syst Lab, Bloomington, IN 47405 USA
关键词
languages; generics; generic programming; constraint propagation; associated types; C#; !text type='Java']Java[!/text;
D O I
10.1145/1103845.1094813
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
Support for object-oriented programming has become an integral part of mainstream languages, and more recently generic programming has gained widespread acceptance as well. A natural question is how these two paradigms, and their underlying language mechanisms, should interact. One particular design option, that of using subtyping to constrain the type parameters of generic functions, has been chosen in the generics of Java and those planned for a future revision of C#. Certain shortcomings have previously been identified in using subtyping for constraining paranietric polymorphism in the context of generic programming. To address these, we propose extending object-oriented interfaces and subtyping to include associated types and constraint propagation. Associated types are type members of interfaces and classes. Constraint propagation allows certain constraints on type parameters to be inferred from other constraints on those parameters and their use in base class type expressions. The paper demonstrates these extensions in the context of C# (with generics), describes a, translation of the extended features to C#, and presents a formalism proving their safety. The formalism is applicable to other mainstream object-oriented languages supporting F-bounded polymorphism, such as Java.
引用
收藏
页码:1 / 19
页数:19
相关论文
共 50 条
  • [1] Lightweight, Flexible Object-Oriented Generics
    Zhang, Yizhou
    Loring, Matthew C.
    Salvaneschi, Guido
    Liskov, Barbara
    Myers, Andrew C.
    ACM SIGPLAN NOTICES, 2015, 50 (06) : 436 - 445
  • [2] Constrained Types for Object-Oriented Languages
    Nystrom, Nathaniel
    Saraswat, Vijay
    Palsberg, Jens
    Grothoff, Christian
    ACM SIGPLAN NOTICES, 2008, 43 (10) : 457 - 474
  • [3] Constrained Types for Object-Oriented Languages
    Nystrom, Nathaniel
    Saraswat, Vijay
    Palsberg, Jens
    Grothoff, Christian
    OOPSLA 2008 NASHVILLE, CONFERENCE PROCEEDINGS: MUSIC CITY USA, OOPSLA, 2008, : 457 - +
  • [4] Generalized algebraic data types and object-oriented programming
    Kennedy, A
    Russo, CV
    ACM SIGPLAN NOTICES, 2005, 40 (10) : 21 - 40
  • [5] On the Pursuit of a Standard Language for Object-Oriented Constraint Modeling
    Soto, Ricardo
    Granvilliers, Laurent
    NEW CHALLENGES IN APPLIED INTELLIGENCE TECHNOLOGIES, 2008, 134 : 123 - 133
  • [6] Using types to analyze and optimize object-oriented programs
    Diwan, A
    McKinley, KS
    Moss, JEB
    ACM TRANSACTIONS ON PROGRAMMING LANGUAGES AND SYSTEMS, 2001, 23 (01): : 30 - 72
  • [7] Modular Session Types for Distributed Object-Oriented Programming
    Gay, Simon J.
    Vasconcclos, Vasco T.
    Ravara, Antonio
    Gesbert, Nils
    Caldeira, Alexandre Z.
    ACM SIGPLAN NOTICES, 2010, 45 (01) : 299 - 312
  • [8] Declaring and checking non-null types in an object-oriented language
    Fähndrich, M
    Rustan, K
    Leino, M
    ACM SIGPLAN NOTICES, 2003, 38 (11) : 302 - 312
  • [9] Associated types and constraint propagation for generic programming in Scala
    A. Pelenitsyn
    Programming and Computer Software, 2015, 41 : 224 - 230
  • [10] Transposing G to C#: Expressivity of generalized algebraic data types in an object-oriented language
    Kennedy, Andrew J.
    Russo, Claudio V.
    THEORETICAL COMPUTER SCIENCE, 2018, 741 : 3 - 18