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).
Supplemental Material
- 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.Google Scholar
- 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. Google Scholar
Digital Library
- 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. Google Scholar
Digital Library
- 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.1607Google Scholar
- 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.Google Scholar
Digital Library
- 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. Google Scholar
Digital Library
- 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. Google Scholar
Digital Library
- Giuseppe Castagna, Giorgio Ghelli, and Giuseppe Longo. 1995. A Calculus for Overloaded Functions with Subtyping. Information and Computation 117, 1 (1995), 115–135. Google Scholar
Digital Library
- 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. Google Scholar
Digital Library
- 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. Google Scholar
Digital Library
- 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. Google Scholar
Digital Library
- 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. Google Scholar
Digital Library
- 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.Google Scholar
- 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 }.Google Scholar
- 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 }.Google Scholar
- 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 }. Google Scholar
Digital Library
- 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.Google Scholar
Cross Ref
- 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. Google Scholar
Digital Library
- 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. Google Scholar
Digital Library
- 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. Google Scholar
Digital Library
- 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. Google Scholar
Digital Library
- Todd Millstein and Craig Chambers. 2002. Modular Statically Typed Multimethods. Information and Computation 175, 1 (2002), 76 – 118.Google Scholar
Cross Ref
- Todd David Millstein. 2003. Reconciling Software Extensibility with Modular Program Reasoning. Ph.D. Dissertation. University of Washington.Google Scholar
- Martin Odersky, Lex Spoon, and Bill Venners. 2016. Programming in Scala (3rd ed.). Artima Press, Walnut Creek, California, USA. ISBN 978-0981531687.Google Scholar
- Gyunghee Park, Jaemin Hong, Guy L. Steele Jr., and Sukyoung Ryu. 2018. Polymorphic Symmetric Multiple Dispatch with Variance (Extended Report).Google Scholar
- Guy Steele and David Chase. 2012. Personal communication.Google Scholar
- 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. Google Scholar
Digital Library
- 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 Google Scholar
Digital Library
- S. Tucker Taft. 2016. Designing ParaSail, a new programming language (blog). http://parasail- programming- language. blogspot.com . Accessed: 2018-04-09.Google Scholar
- 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. Google Scholar
Digital Library
- 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.Google Scholar
- Andrew K. Wright and Matthias Felleisen. 1994. A Syntactic Approach to Type Soundness. Information and Computation 115, 1 (Nov. 1994), 38–94. Google Scholar
Digital Library
Index Terms
Polymorphic symmetric multiple dispatch with variance
Recommendations
On polymorphic gradual typing
We study an extension of gradual typing—a method to integrate dynamic typing and static typing smoothly in a single language—to parametric polymorphism and its theoretical properties, including conservativity of typing and semantics over both statically ...
Polymorphic algebraic data type reconstruction
PPDP '06: Proceedings of the 8th ACM SIGPLAN international conference on Principles and practice of declarative programmingOne of the disadvantages of statically typed languages is the programming overhead caused by writing all the necessary type information: Both type declarations and type definitions are typically required. Traditional type inference aims at relieving the ...
Polymorphic Manifest Contracts, Revised and Resolved
Manifest contracts track precise program properties by refining types with predicates—for example, {x:Int∣ x > 0} denotes the positive integers. Contracts and polymorphism make a natural combination: programmers can give strong contracts to abstract ...






Comments