Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
10.1145/949305.949316acmconferencesArticle/Chapter ViewAbstractPublication PagessplashConference Proceedingsconference-collections
Article

A first-class approach to genericity

Published: 26 October 2003 Publication History
  • Get Citation Alerts
  • Abstract

    This paper describes how to add first-class generic types---including mixins---to strongly-typed OO 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 Cpp (via templates), they are clumsy and error-prone because Cpp 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.

    References

    [1]
    O. Agesen, S. Freund, and J. Mitchell. Adding type parameterization to the Java language. In OOPSLA, 1997.]]
    [2]
    E. Allen, J. Bannet, and R. Cartwright. Mixins in Generic Java are sound. Technical report, Rice University, 2002.]]
    [3]
    E. Allen and R. Cartwright. The case for run-time types in Generic Java. In Principles and Practice of Programming in Java, 2002.]]
    [4]
    E. Allen and R. Cartwright. Safe instantiation in Generic Java. In Technical Report, Computer Science Department, Rice University, 2003. Available at http://www.cs.rice.edu/CS/PLT/Publications.]]
    [5]
    E. Allen, R. Cartwright, and B. Stoler. Efficient implementation of run-time generic types for Java. In IFIP WG2.1 Working Conference on Generic Programming, 2002.]]
    [6]
    D. Ancona, G.Lagorio, and E.Zucca. JAM--a smooth extension of Java with mixins. In ECOOP, 2000.]]
    [7]
    D. Ancona and E. Zucca. A theory of mixin modules: Basic and derived operators. In Mathematical Structures in Computer Science, pages 8(4):401--446, 1998.]]
    [8]
    D. Ancona and E. Zucca. A theory of mixin modules: algebraic laws and reduction semantics. Mathematical Structures in Computer Science, 12(6):701--737, 2002.]]
    [9]
    J. Bloch and N. Gafter. Personal communication, 2002.]]
    [10]
    G. Bracha. The Programming Language Jigsaw: Mixins, Modularity, and Multiple Inheritance. PhD thesis, University of Utah, 1992.]]
    [11]
    G. Bracha and W. Cook. Mixin-based inheritance. In OOPSLA, 1990.]]
    [12]
    G. Bracha, M. Odersky, D. Stoutamire, and P. Wadler. GJ Specification, 1998.]]
    [13]
    G. Bracha, M. Odersky, D. Stoutamire, and P. Wadler. Making the future safe for the past: Adding genericity to the Java programming language. In OOPSLA, 1998.]]
    [14]
    L. Cardelli, S. Martini, J. Mitchell, and A. Scedrov. An extension of system f with subtyping. Information and Computation 109(1-2), pages 4--56, 1994.]]
    [15]
    R. Cartwright and G. Steele. Compatible genericity with run-time types for the Java programming language. In OOPSLA, 1998.]]
    [16]
    M. Flatt, S. Krishnamurthi, and M. Felleisen. A programmer's reduction semantics for classes and mixins. In Formal Syntax and Semantics of Java. Springer-Verlag, 2000.]]
    [17]
    E. Gamma, R. Helm, R. Johnson, and J. Vlissides. Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley, 1995.]]
    [18]
    A. Igarashi, B. Pierce, and P. Wadler. Featherweight Java: A minimal core calculus for Java and GJ. In OOPSLA, 1999.]]
    [19]
    A. Kennedy and D. Syme. Design and implementation of generics for the .net common language runtime. In PLDI, 2001.]]
    [20]
    S. McDirmid, M. Flatt, and W. Hsieh. Jiazzi: New age components for old fashioned Java. In OOPSLA, 2001.]]
    [21]
    D. Moon. Object-oriented programming with Flavors. In OOPSLA, 1986.]]
    [22]
    A. Myers, J. Bank, and B. Liskov. Parameterized types for Java. In POPL, 1997.]]
    [23]
    M. Odersky and P. Wadler. Pizza into Java: Translating theory into practice. In POPL, 1997.]]
    [24]
    B. Pierce. Types and Programming Languages. MIT Press, 2002.]]
    [25]
    A. Snyder. CommonObjects: An overview. In SIGPLAN Workshop on Object-oriented Programming, 1986.]]
    [26]
    Sun Microsystems, Inc. JSR 14: Add generic types to the Java Programming Language, 2001.]]
    [27]
    Sun Microsystems, Inc. JSR-14 v1.3 prototype compiler source code, 2003. Available at http://www.jcp.org/en/jsr/detail?id=014.]]

    Cited By

    View all
    • (2020)Legodroid: A Type-Driven Library for Android and LEGO Mindstorms InteroperabilitySensors10.3390/s2007192620:7(1926)Online publication date: 30-Mar-2020
    • (2016)Matriona: class nesting with parameterization in Squeak/SmalltalkProceedings of the 15th International Conference on Modularity10.1145/2889443.2889457(118-129)Online publication date: 14-Mar-2016
    • (2013)Contracts for First-Class ClassesACM Transactions on Programming Languages and Systems10.1145/251818935:3(1-58)Online publication date: 1-Nov-2013
    • Show More Cited By

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image ACM Conferences
    OOPSLA '03: Proceedings of the 18th annual ACM SIGPLAN conference on Object-oriented programing, systems, languages, and applications
    October 2003
    430 pages
    ISBN:1581137125
    DOI:10.1145/949305
    • cover image ACM SIGPLAN Notices
      ACM SIGPLAN Notices  Volume 38, Issue 11
      Special Issue: Proceedings of the OOPSLA '03 conference
      November 2003
      417 pages
      ISSN:0362-1340
      EISSN:1558-1160
      DOI:10.1145/949343
      Issue’s Table of Contents
    Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

    Sponsors

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 26 October 2003

    Permissions

    Request permissions for this article.

    Check for updates

    Qualifiers

    • Article

    Conference

    OOPSLA03
    Sponsor:

    Acceptance Rates

    OOPSLA '03 Paper Acceptance Rate 26 of 147 submissions, 18%;
    Overall Acceptance Rate 268 of 1,244 submissions, 22%

    Upcoming Conference

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)2
    • Downloads (Last 6 weeks)0

    Other Metrics

    Citations

    Cited By

    View all
    • (2020)Legodroid: A Type-Driven Library for Android and LEGO Mindstorms InteroperabilitySensors10.3390/s2007192620:7(1926)Online publication date: 30-Mar-2020
    • (2016)Matriona: class nesting with parameterization in Squeak/SmalltalkProceedings of the 15th International Conference on Modularity10.1145/2889443.2889457(118-129)Online publication date: 14-Mar-2016
    • (2013)Contracts for First-Class ClassesACM Transactions on Programming Languages and Systems10.1145/251818935:3(1-58)Online publication date: 1-Nov-2013
    • (2012)Constrained kindsACM SIGPLAN Notices10.1145/2398857.238467547:10(811-830)Online publication date: 19-Oct-2012
    • (2012)Constrained kindsProceedings of the ACM international conference on Object oriented programming systems languages and applications10.1145/2384616.2384675(811-830)Online publication date: 19-Oct-2012
    • (2012)MagdaProceedings of the 26th European conference on Object-Oriented Programming10.1007/978-3-642-31057-7_25(560-588)Online publication date: 11-Jun-2012
    • (2011)MorphingACM Transactions on Programming Languages and Systems10.1145/1890028.189002933:2(1-44)Online publication date: 7-Feb-2011
    • (2010)Contracts for first-class classesACM SIGPLAN Notices10.1145/1899661.186964245:12(97-112)Online publication date: 18-Oct-2010
    • (2010)Contracts for first-class classesProceedings of the 6th symposium on Dynamic languages10.1145/1869631.1869642(97-112)Online publication date: 18-Oct-2010
    • (2009)Implicit First Class GenericityProceedings of the 8th International Conference on Software Composition10.1007/978-3-642-02655-3_9(107-124)Online publication date: 30-Jun-2009
    • Show More Cited By

    View Options

    Get Access

    Login options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Media

    Figures

    Other

    Tables

    Share

    Share

    Share this Publication link

    Share on social media