Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
research-article
Open access

Polymorphic symmetric multiple dispatch with variance

Published: 02 January 2019 Publication History

Abstract

Many object-oriented languages provide method overloading, which allows multiple method declarations with the same name. For a given method invocation, in order to choose what method declaration to invoke, multiple dispatch considers the run-time types of the arguments. While multiple dispatch can support binary methods (such as mathematical operators) intuitively and consistently, it is difficult to guarantee that calls will be neither ambiguous nor undefined at run time, especially in the presence of expressive language features such as multiple inheritance and parametric polymorphism. Previous efforts have formalized languages that include such features by using overloading rules that guarantee a unique and type-sound resolution of each overloaded method call; in many cases, such rules resolve ambiguity by treating the arguments asymmetrically. Here we present the first formal specification of a strongly typed object-oriented language with symmetric multiple dispatch, multiple inheritance, and parametric polymorphism with variance. We define both a static (type- checking) semantics and a dynamic (dispatching) semantics and prove the type soundness of the language, thus demonstrating that our novel dynamic dispatch algorithm is consistent with the static semantics. Details of our dynamic dispatch algorithm address certain technical challenges that arise from structural asymmetries inherent in object-oriented languages (e.g., classes typically declare ancestors explicitly but not descendants).

Supplementary Material

WEBM File (a11-park.webm)

References

[1]
Eric Allen, David Chase, J. J. Hallett, Victor Luchangco, Jan-Willem Maessen, Sukyoung Ryu, Guy L. Steele Jr., and Sam Tobin-Hochstadt. 2008. The Fortress Language Specification Version 1.0.
[2]
Eric Allen, J. J. Hallett, Victor Luchangco, Sukyoung Ryu, and Guy L. Steele Jr. 2007. Modular Multiple Dispatch with Multiple Inheritance. In Proceedings of the 2007 ACM Symposium on Applied Computing (SAC ’07). ACM, New York, NY, USA, 1117–1121.
[3]
Eric Allen, Justin Hilburn, Scott Kilpatrick, Victor Luchangco, Sukyoung Ryu, David Chase, and Guy L. Steele Jr. 2011. Type-checking Modular Multiple Dispatch with Parametric Polymorphism and Multiple Inheritance. In Proceedings of the ACM International Conference on Object Oriented Programming, Systems, Languages, and Applications (OOPSLA ’11). ACM, New York, NY, USA, 973–992.
[4]
Jeff Bezanson, Alan Edelman, Stefan Karpinski, and Viral B. Shah. 2015. Julia: A Fresh Approach to Numerical Computing (v4). CoRR abs/1411.1607 (July 2015), 1–37. http://arxiv.org/abs/1411.1607
[5]
Jeff Bezanson, Alan Edelman, Stefan Karpinski, and Viral B. Shah. 2017. Julia: A Fresh Approach to Numerical Computing. SIAM Rev. 59, 1 (2017), 65–98.
[6]
François Bourdoncle and Stephan Merz. 1997. Type Checking Higher-Order Polymorphic Multi-methods. In Proceedings of the 24th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’97). ACM, New York, NY, USA, 302–315.
[7]
Giuseppe Castagna, Giorgio Ghelli, and Giuseppe Longo. 1992. A Calculus for Overloaded Functions with Subtyping. In Proceedings of the 1992 ACM Conference on LISP and Functional Programming (LFP ’92). ACM, New York, NY, USA, 182–192.
[8]
Giuseppe Castagna, Giorgio Ghelli, and Giuseppe Longo. 1995. A Calculus for Overloaded Functions with Subtyping. Information and Computation 117, 1 (1995), 115–135.
[9]
Giuseppe Castagna, Kim Nguyen, Zhiwu Xu, and Pietro Abate. 2015. Polymorphic Functions with Set-Theoretic Types: Part 2: Local Type Inference and Type Reconstruction. In Proceedings of the 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’15). ACM, New York, NY, USA, 289–302.
[10]
Curtis Clifton, Gary T. Leavens, Craig Chambers, and Todd Millstein. 2000. MultiJava: Modular Open Classes and Symmetric Multiple Dispatch for Java. In Proceedings of the 15th ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA ’00). ACM, New York, NY, USA, 130–145.
[11]
Curtis Clifton, Todd D. Millstein, Gary T. Leavens, and Craig Chambers. 2006. MultiJava: Design Rationale, Compiler Implementation, and Applications. ACM Transactions on Programming Languages and Systems 28, 3 (May 2006), 517–575.
[12]
Devin Coughlin and Bor-Yuh Evan Chang. 2014. Fissile Type Analysis: Modular Checking of Almost Everywhere Invariants. In Proceedings of the 41st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’14). Association for Computing Machinery, New York, 73–85.
[13]
EPFL. 2017. A class for immutable linked lists representing ordered collections of elements of type ‘A‘ {implementation of class List for the Scala programming language}. https://github.com/scala/scala/blob/2.13.x/src/library/scala/collection/ immutable/List.scala . Accessed: 2017-11-27.
[14]
Jacques Garrigue. 2001. Simple Type Inference for Structural Polymorphism. In Proceedings of the Second Asian Workshop on Programming Languages and Systems (APLAS’01). 329–343. Also presented as { Garrigue 2002 }.
[15]
Jacques Garrigue. 2002. Simple Type Inference for Structural Polymorphism. In Ninth International Workshop on Foundations of Object-Oriented Languages. 1–11. http://www.cs.cmu.edu/{\char’ 176}aldrich/FOOL/papers9/garrigue.ps Also presented as { Garrigue 2001 }.
[16]
Jacques Garrigue. 2010. A Certified Implementation of ML with Structural Polymorphism. In Programming Languages and Systems, Kazunori Ueda (Ed.). Springer Berlin Heidelberg, 360–375. LNCS 6461. Proceedings of the Eighth Asian Symposium on Programming Languages and Systems (APLAS 2010), Shanghai, China. More complete journal version is { Garrigue 2015 }.
[17]
Jacques Garrigue. 2015. A Certified Implementation of ML with Structural Polymorphism and Recursive Types. Mathematical Structures in Computer Science 25, 4 (May 2015), 867–891.
[18]
Atsushi Igarashi and Mirko Viroli. 2006. Variant Parametric Types: A Flexible Subtyping Scheme for Generics. ACM Transactions on Programming Languages and Systems 28, 5 (September 2006), 795–847.
[19]
Jieung Kim and Sukyoung Ryu. 2011. Coq Mechanization of Featherweight Fortress with Multiple Dispatch and Multiple Inheritance. In Certified Programs and Proofs (CPP ’11), Jean-Pierre Jouannaud and Zhong Shao (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg, 264–279.
[20]
Keunwoo Lee and Craig Chambers. 2006. Parameterized Modules for Classes and Extensible Functions. In ECOOP 2006 – Object-Oriented Programming, Dave Thomas (Ed.). Springer Berlin Heidelberg, Berlin, Heidelberg, 353–378.
[21]
Todd Millstein and Craig Chambers. 1999. Modular Statically Typed Multimethods. In ECOOP’ 99 — Object-Oriented Programming, Rachid Guerraoui (Ed.). Springer Berlin Heidelberg, Berlin, Heidelberg, 279–303.
[22]
Todd Millstein and Craig Chambers. 2002. Modular Statically Typed Multimethods. Information and Computation 175, 1 (2002), 76 – 118.
[23]
Todd David Millstein. 2003. Reconciling Software Extensibility with Modular Program Reasoning. Ph.D. Dissertation. University of Washington.
[24]
Martin Odersky, Lex Spoon, and Bill Venners. 2016. Programming in Scala (3rd ed.). Artima Press, Walnut Creek, California, USA. ISBN 978-0981531687.
[25]
Gyunghee Park, Jaemin Hong, Guy L. Steele Jr., and Sukyoung Ryu. 2018. Polymorphic Symmetric Multiple Dispatch with Variance (Extended Report).
[26]
Guy Steele and David Chase. 2012. Personal communication.
[27]
Guy L. Steele Jr. 2017. It’s Time for a New Old Language. Published on YouTube. https://youtu.be/7HKbjYqqPPQ Video (TRT 1:12:11) of invited keynote talk at PPoPP ’17: 22nd ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming, Austin, Texas, February 6, 2017.
[28]
S. Tucker Taft. 2011. Multicore Programming in ParaSail: Parallel Specification and Implementation Language. In Proceedings of the 16th Ada-Europe International Conference on Reliable Software Technologies (Ada-Europe’11). Springer-Verlag, Berlin, Heidelberg, 196–200. http://dl.acm.org/citation.cfm?id=2018027.2018049
[29]
S. Tucker Taft. 2016. Designing ParaSail, a new programming language (blog). http://parasail- programming- language. blogspot.com . Accessed: 2018-04-09.
[30]
Dimitrios Vytiniotis, Simon Peyton Jones, Koen Claessen, and Dan Rosén. 2013. HALO: Haskell to Logic through Denotational Semantics. In Proceedings of the 40th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’13). Association for Computing Machinery, New York, 431–442.
[31]
Yanlin Wang, Haoyuan Zhang, Bruno C. d. S. Oliveira, and Marco Servetto. 2018. FHJ: A Formal Model for Hierarchical Dispatching and Overriding. In 32nd European Conference on Object-Oriented Programming, ECOOP 2018, July 16-21, 2018, Amsterdam, The Netherlands. 20:1–20:30.
[32]
Andrew K. Wright and Matthias Felleisen. 1994. A Syntactic Approach to Type Soundness. Information and Computation 115, 1 (Nov. 1994), 38–94.

Cited By

View all
  • (2022)Formalizing ϕ-Calculus: A Purely Object-Oriented Calculus of Decorated ObjectsProceedings of the 24th ACM International Workshop on Formal Techniques for Java-like Programs10.1145/3611096.3611103(29-36)Online publication date: 7-Jun-2022
  • (2021)Taming the Merge OperatorJournal of Functional Programming10.1017/S095679682100018631Online publication date: 2-Nov-2021
  • (2019)Decidable tag-based semantic subtyping for nominal types, tuples, and unionsProceedings of the 21st Workshop on Formal Techniques for Java-like Programs10.1145/3340672.3341115(1-11)Online publication date: 15-Jul-2019

Recommendations

Comments

Information & Contributors

Information

Published In

cover image Proceedings of the ACM on Programming Languages
Proceedings of the ACM on Programming Languages  Volume 3, Issue POPL
January 2019
2275 pages
EISSN:2475-1421
DOI:10.1145/3302515
Issue’s Table of Contents
This work is licensed under a Creative Commons Attribution-NoDerivs International 4.0 License.

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 02 January 2019
Published in PACMPL Volume 3, Issue POPL

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. Method Overloading
  2. Parametric Polymorphism
  3. Symmetric Multiple Dispatch
  4. Variance

Qualifiers

  • Research-article

Funding Sources

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)156
  • Downloads (Last 6 weeks)26
Reflects downloads up to 09 Jan 2025

Other Metrics

Citations

Cited By

View all
  • (2022)Formalizing ϕ-Calculus: A Purely Object-Oriented Calculus of Decorated ObjectsProceedings of the 24th ACM International Workshop on Formal Techniques for Java-like Programs10.1145/3611096.3611103(29-36)Online publication date: 7-Jun-2022
  • (2021)Taming the Merge OperatorJournal of Functional Programming10.1017/S095679682100018631Online publication date: 2-Nov-2021
  • (2019)Decidable tag-based semantic subtyping for nominal types, tuples, and unionsProceedings of the 21st Workshop on Formal Techniques for Java-like Programs10.1145/3340672.3341115(1-11)Online publication date: 15-Jul-2019

View Options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Login options

Full Access

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media