skip to main content
research-article

Type checking modular multiple dispatch with parametric polymorphism and multiple inheritance

Published:22 October 2011Publication History
Skip Abstract Section

Abstract

In previous work, we presented rules for defining overloaded functions that ensure type safety under symmetric multiple dispatch in an object-oriented language with multiple inheritance, and we showed how to check these rules without requiring the entire type hierarchy to be known, thus supporting modularity and extensibility. In this work, we extend these rules to a language that supports parametric polymorphism on both classes and functions.

In a multiple-inheritance language in which any type may be extended by types in other modules, some overloaded functions that might seem valid are correctly rejected by our rules. We explain how these functions can be permitted in a language that additionally supports an exclusion relation among types, allowing programmers to declare "nominal exclusions" and also implicitly imposing exclusion among different instances of each polymorphic type. We give rules for computing the exclusion relation, deriving many type exclusions from declared and implicit ones.

We also show how to check our rules for ensuring the safety of overloaded functions. In particular, we reduce the problem of handling parametric polymorphism to one of determining subtyping relationships among universal and existential types. Our system has been implemented as part of the open-source Fortress compiler.

References

  1. Eric Allen, David Chase, Joe Hallett, Victor Luchangco, Jan-Willem Maessen, Sukyoung Ryu, Guy L. Steele Jr., and Sam Tobin-Hochstadt. The Fortress Language Specification Version 1.0, March 2008.Google ScholarGoogle Scholar
  2. Eric Allen, J. J. Hallett, Victor Luchangco, Sukyoung Ryu, and Guy L. Steele Jr. Modular multiple dispatch with multiple inheritance. In SAC '07, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. François Bourdoncle and Stephan Merz. Type checking higher-order polymorphic multi-methods. In POPL '97, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Giuseppe Castagna, Giorgio Ghelli, and Giuseppe Longo. A calculus for overloaded functions with subtyping. Information and Computation, 117(1):115--135, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Curtis Clifton, Todd Millstein, Gary T. Leavens, and Craig Chambers. MultiJava: Design rationale, compiler implementation, and applications. ACM TOPLAS, 28(3), 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Derek Dreyer, Robert Harper, and Manuel M. T. Chakravarty. Modular type classes. In POPL '07, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. James Gosling, Bill Joy, Guy Steele, and Gilad Bracha. The Java Language Specification, Third Edition. Addison-Wesley Longman, Amsterdam, 3 edition, June 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Andrew J. Kennedy and Benjamin C. Pierce. On decidability of nominal subtyping with variance, September 2006. FOOL-WOOD '07.Google ScholarGoogle Scholar
  9. Keunwoo Lee and Craig Chambers. Parameterized modules for classes and extensible functions. In ECOOP '06, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Vassily Litvinov. Constraint-based polymorphism in Cecil: Towards a practical and static type system. In OOPSLA '98, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Todd Millstein and Craig Chambers. Modular statically typed multimethods. Information and Computation, 175(1):76--118, 2002.Google ScholarGoogle ScholarCross RefCross Ref
  12. Todd David Millstein. Reconciling software extensibility with modular program reasoning. PhD thesis, University of Washington, 2003.Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Martin Odersky. The Scala Language Specification, Version 2.7. EPFL Lausanne, Switzerland, 2009.Google ScholarGoogle Scholar
  14. Jeremy G. Siek. A language for generic programming. PhD thesis, Indiana University, Indianapolis, IN, USA, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Vincent Simonet and François Pottier. A constraint-based approach to guarded algebraic data types. ACM Trans. Program. Lang. Syst., 29(1):1, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Daniel Smith and Robert Cartwright. Java type inference is broken: can we fix it? In OOPSLA '08, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. P. Wadler and S. Blott. How to make ad-hoc polymorphism less ad hoc. In POPL '89, 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Stefan Wehr, Ralf Lommel, and Peter Thiemann. JavaGI: Generalized interfaces for Java. In ECOOP 2007, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Type checking modular multiple dispatch with parametric polymorphism and multiple inheritance

          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

          Full Access

          • Published in

            cover image ACM SIGPLAN Notices
            ACM SIGPLAN Notices  Volume 46, Issue 10
            OOPSLA '11
            October 2011
            1063 pages
            ISSN:0362-1340
            EISSN:1558-1160
            DOI:10.1145/2076021
            Issue’s Table of Contents
            • cover image ACM Conferences
              OOPSLA '11: Proceedings of the 2011 ACM international conference on Object oriented programming systems languages and applications
              October 2011
              1104 pages
              ISBN:9781450309400
              DOI:10.1145/2048066

            Copyright © 2011 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: 22 October 2011

            Check for updates

            Qualifiers

            • research-article

          PDF Format

          View or Download as a PDF file.

          PDF

          eReader

          View online with eReader.

          eReader