skip to main content
10.1145/1094811.1094813acmconferencesArticle/Chapter ViewAbstractPublication PagessplashConference Proceedingsconference-collections
Article

Associated types and constraint propagation for mainstream object-oriented generics

Published:12 October 2005Publication History

ABSTRACT

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 parametric 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.

References

  1. Stepanov, A., Lee, M.: The Standard Template Library. Technical Report HPL-94-34(R.1), Hewlett-Packard Laboratories (1994) http://www.hpl.hp.com/techreports.]]Google ScholarGoogle Scholar
  2. Stepanov, A.: The Standard Template Library --- how do you build an algorithm that is both generic and efficient? Byte Magazine 20 (1995)]]Google ScholarGoogle Scholar
  3. An, P., Jula, A., Rus, S., Saunders, S., Smith, T., Tanase, G., Thomas, N., Amato, N., Rauchwerger, L.: STAPL: An adaptive, generic parallel C++ library. In: Languages and Compilers for Parallel Computing. Volume 2624 of Lecture Notes in Computer Science. Springer (2001) 193--208]]Google ScholarGoogle Scholar
  4. Siek, J., Lee, L.Q., Lumsdaine, A.: The Boost Graph Library: User Guide and Reference Manual. Addison-Wesley (2002)]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Siek, J., Lumsdaine, A.: A modern framework for portable high performance numerical linear algebra. In: Modern Software Tools for Scientific Computing. Birkhäuser (1999)]]Google ScholarGoogle Scholar
  6. Pitt, W.R., Williams, M.A., Steven, M., Sweeney, B., Bleasby, A.J., Moss, D.S.: The Bioinformatics Template Library--generic components for biocomputing. Bioinformatics 17 (2001) 729--737]]Google ScholarGoogle ScholarCross RefCross Ref
  7. Microsoft Corporation: C# Version 2.0 Specification, March 2005 Draft. (2005) http://msdn.microsoft.com/vcsharp/programming/language.]]Google ScholarGoogle Scholar
  8. Garcia, R., Järvi, J., Lumsdaine, A., Siek, J., Willcock, J.: A comparative study of language support for generic programming. In: OOPSLA '03: Proceedings of the 18th annual ACM SIGPLAN conference on Object-oriented programing, systems, languages, and applications, New York, NY, USA, ACM Press (2003) 115--134]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Madsen, O.L., Moller-Pedersen, B.: Virtual classes: a powerful mechanism in object-oriented programming. In: OOPSLA '89: Conference proceedings on Object-oriented programming systems, languages and applications, ACM Press (1989) 397--406]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Thorup, K.K.: Genericity in Java with virtual types. In: ECOOP '97. Volume 1241 of Lecture Notes in Computer Science. (1997) 444--471]]Google ScholarGoogle Scholar
  11. Canning, P., Cook, W., Hill, W., Olthoff, W., Mitchell, J.C.: F-bounded polymorphism for object-oriented programming. In: FPCA '89: Proceedings of the fourth international conference on Functional programming languages and computer architecture, New York, NY, USA, ACM Press (1989) 273--280]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Igarashi, A., Pierce, B.C., Wadler, P.: Featherweight Java: a minimal core calculus for Java and GJ. ACM Trans. Program. Lang. Syst. 23 (2001) 396--450]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Kennedy, A., Syme, D.: Transposing F to C#: Expressivity of polymorphism in an object-oriented language. Concurrency and Computation: Practice and Experience 16 (2004) 707--733]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Jazayeri, M., Loos, R., Musser, D., Stepanov, A.: Generic Programming. In: Report of the Dagstuhl Seminar on Generic Programming, Schloss Dagstuhl, Germany (1998)]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Kapur, D., Musser, D.: Tecton: a framework for specifying and verifying generic system components. Technical Report RPI--92--20, Department of Computer Science, Rensselaer Polytechnic Institute, Troy, New York 12180 (1992)]]Google ScholarGoogle Scholar
  16. Austern, M.H.: Generic Programming and the STL. Professional computing series. Addison-Wesley (1999)]]Google ScholarGoogle Scholar
  17. Silicon Graphics, Inc.: SGI Implementation of the Standard Template Library. (2004) http://www.sgi.com/tech/stl/.]]Google ScholarGoogle Scholar
  18. International Organization for Standardization: ISO/IEC 14882:1998: Programming languages --- C++, Geneva, Switzerland (1998)]]Google ScholarGoogle Scholar
  19. Bruce, K.B., Fiech, A., Petersen, L.: Subtyping is not a good "match" for object-oriented languages. In: ECOOP '97. Volume 1241 of Lecture Notes in Computer Science., Springer-Verlag (1997) 104--127]]Google ScholarGoogle Scholar
  20. Thorup, K.K., Torgersen, M.: Unifying genericity --- combining the benefits of virtual types and parameterized classes. In: ECOOP '99. Volume 1628 of Lecture Notes in Computer Science., Springer-Verlag (1999) 186--204]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Nystrom, N., Chong, S., Myers, A.C.: Scalable extensibility via nested inheritance. In: OOPSLA '04: Proceedings of the 19th annual ACM SIGPLAN Conference on Object-oriented programming, systems, languages, and applications, ACM Press (2004) 99--115]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Torgersen, M.: Virtual types are statically safe. In: FOOL 5: Workshop on Foundations of Object-Oriented Languages. (1998) http://pauillac.inria.fr/~remy/fool/.]]Google ScholarGoogle Scholar
  23. Bruce, K.B., Cardelli, L., Castagna, G., Eifrig, J., Smith, S.F., Trifonov, V., Leavens, G.T., Pierce, B.C.: On binary methods. Theory and Practice of Object Systems 1 (1995) 221--242]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Bruce, K.B., Odersky, M., Wadler, P.: A statically safe alternative to virtual types. In: ECOOP '98. Volume 1445. (1998) 523--549]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Bruce, K.B., Vanderwaart, J.C.: Semantics-driven language design: Statically type-safe virtual types in object-oriented languages. In: Mathematical Foundations of Programming Semantics. Volume 20 of Electronic Notes in Theoretical Computer Science. (2000)]]Google ScholarGoogle Scholar
  26. Ernst, E.: Family polymorphism. In: ECOOP '01. Volume 2072 of Lecture Notes in Computer Science., Springer (2001) 303--326]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Odersky, M., Cremet, V., Röckl, C., Zenger, M.: A nominal theory of objects with dependent types. In: ECOOP '03. Volume 2743 of Lecture Notes in Computer Science., Springer-Verlag (2003) 201--224]]Google ScholarGoogle Scholar
  28. Odersky, M., Altherr, P., Cremet, V., Emir, B., et al.: The Scala Language Specification. Programming Methods Laboratory, EPFL. Version 1.0 edn. (2005) http://scala.epfl.ch/docu/files/ScalaReference.pdf.]]Google ScholarGoogle Scholar
  29. Odersky, M., Zenger, C.: Nested types. In: FOOL 8: Workshop on Foundations of Object-Oriented Languages. (2001)]]Google ScholarGoogle Scholar
  30. Myers, N.: A new and useful technique: "traits". C++ Report 7 (1995) 32--35]]Google ScholarGoogle Scholar
  31. Milner, R., Tofte, M., Harper, R.: The Definition of Standard ML. MIT Press (1990)]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Jones, M.P.: Type classes with functional dependencies. In: ESOP '00: Proceedings of the 9th European Symposium on Programming Languages and Systems. Volume 1782 of Lecture Notes in Computer Science., New York, NY, Springer-Verlag (2000) 230--244]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Chakravarty, M.M.T., Keller, G., Peyton Jones, S., Marlow, S.: Associated types with class. In: POPL '05: Proceedings of the 32nd ACM SIGPLAN-SIGACT symposium on Principles of programming languages, New York, NY, USA, ACM Press (2005) 1--13]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. Chakravarty, M.M.T., Keller, G., Peyton Jones, S.: Associated type synonyms. In: Proceedings of the International Conference on Functional Programming (ICFP '05), New York, NY, USA, ACM Press (2005)]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. Chambers, C., the Cecil Group: The Cecil Language: Specification and Rationale, Version 3.1. University of Washington, Computer Science and Engineering. (2002) http://www.cs.washington.edu/research/projects/cecil/.]]Google ScholarGoogle Scholar
  36. Torgersen, M., Hansen, C.P., Ernst, E., von der Ahé, P., Bracha, G., Gafter, N.: Adding wildcards to the Java programming language. In: ACM Symposium on Applied computing, ACM Press (2004) 1289--1296]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. Torgersen, M., Ernst, E., Hansen, C.P.: Wild FJ. In: FOOL 12: Workshop on Foundations of Object-Oriented Languages. (2005)]]Google ScholarGoogle Scholar
  38. Wadler, P., Blott, S.: How to make ad-hoc polymorphism less ad-hoc. In: ACM Symposium on Principles of Programming Languages, ACM (1989) 60--76]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. http://research.cs.tamu.edu/jarvi/csharp (2005)]]Google ScholarGoogle Scholar

Index Terms

  1. Associated types and constraint propagation for mainstream object-oriented generics

        Recommendations

        Comments

        Login options

        Check if you have access through your login credentials or your institution to get full access on this article.

        Sign in
        • Published in

          cover image ACM Conferences
          OOPSLA '05: Proceedings of the 20th annual ACM SIGPLAN conference on Object-oriented programming, systems, languages, and applications
          October 2005
          562 pages
          ISBN:1595930310
          DOI:10.1145/1094811
          • cover image ACM SIGPLAN Notices
            ACM SIGPLAN Notices  Volume 40, Issue 10
            Proceedings of the 20th annual ACM SIGPLAN conference on Object oriented programming systems languages and applications
            October 2005
            531 pages
            ISSN:0362-1340
            EISSN:1558-1160
            DOI:10.1145/1103845
            Issue’s Table of Contents

          Copyright © 2005 ACM

          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]

          Publisher

          Association for Computing Machinery

          New York, NY, United States

          Publication History

          • Published: 12 October 2005

          Permissions

          Request permissions about this article.

          Request Permissions

          Check for updates

          Qualifiers

          • Article

          Acceptance Rates

          Overall Acceptance Rate268of1,244submissions,22%

          Upcoming Conference

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader