skip to main content
research-article

Multiple dispatch in practice

Published: 19 October 2008 Publication History

Abstract

Multiple dispatch uses the run time types of more than one argument to a method call to determine which method body to run. While several languages over the last 20 years have provided multiple dispatch, most object-oriented languages still support only single dispatch forcing programmers to implement multiple dispatch manually when required. This paper presents an empirical study of the use of multiple dispatch in practice, considering six languages that support multiple dispatch, and also investigating the potential for multiple dispatch in Java programs. We hope that this study will help programmers understand the uses and abuses of multiple dispatch; virtual machine implementors optimise multiple dispatch; and language designers to evaluate the choice of providing multiple dispatch in new programming languages.

References

[1]
Gareth Baxter, Marcus Frean, James Noble, Mark Rickerby, Hayden Smith, Matt Visser, Hayden Melton, and Ewan Tempero. Understanding the shape of Java software. In OOPSLA, pages 397--412, Portland, OR, USA, 2006. ACM Press.
[2]
Daniel G. Bobrow. The LOOPS Manual. Xerox Parc, 1983.
[3]
Daniel G. Bobrow, Kenneth Kahn, Gregor Kiczales, Larry Masinter, Mark Stefik, and Frank Zdybel. CommonLoops: Merging Lisp and object-oriented programming. SIGPLAN Not, 21:17--29, 1986.
[4]
Daniel G. Bobrow, Linda G. DeMichiel, Richard P. Gabriel, Sonya E. Keene, Gregor Kiczales, and David A. Moon. Common Lisp Object System specification. SIGPLAN Not, 23:1--142, 1988.
[5]
Daniel Bonniot, Bryn Keller, and Francis Barber. The Nice user's manual, 2008. URL http://nice.sourceforge.net/ manual.html.
[6]
John Boyland and Giuseppe Castagna. Parasitic Methods: An implementation of multi-methods for Java. In OOPSLA, pages 66--76. ACM Press, 1997.
[7]
Kim B. Bruce, Luca Cardelli, Giuseppe Castagna, Jonathan Eifrig, Scott F. Smith, Valery Trifonov, Gary T. Leavens, and Benjamin C. Pierce. On binary methods. Theory and Practice of Object Systems, 1:221--242, 1995.
[8]
Bruno Cabral and Paulo Marques. Exception Handling: A field study in Java and .NET. In ECOOP, volume 4609, pages 151--175. Springer-Verlag, 2007.
[9]
Patrice Chalin and Perry R. James. Non-null references by default in Java: Alleviating the nullity annotation burden. In ECOOP, volume 4609, pages 227--247. Springer-Verlag, 2007.
[10]
Craig Chambers. The Diesel Language, specification and rationale, 2006. URL http://www.cs.washington.edu/research/projects/cecil/www/Release/doc-diesel-lang/diesel-spec.pdf.
[11]
Craig Chambers. Object-oriented multi-methods in Cecil. In ECOOP, volume 615, pages 33--56. Springer-Verlag, 1992.
[12]
Craig Chambers andWeimin Chen. Efficient multiple and predicated dispatching. In OOPSLA, pages 238--255, Denver, CO, USA, 1999. ACM Press.
[13]
Curtis Clifton, Gary T. Leavens, Craig Chambers, and Todd Millstein. MultiJava: Modular open classes and symmetric multiple dispatch for Java. In OOPSLA, pages 130--145, Minneapolis, MN, USA, 2000. ACM Press.
[14]
Curtis Clifton, Todd Millstein, Gary T. Leavens, and Craig Chambers. MultiJava: Design rationale, compiler implementation, and applications. TOPLAS, 28:517--575, 2006.
[15]
Antonio Cunei and Jan Vitek. PolyD: a flexible dispatching framework. In OOPSLA, pages 487--503, San Diego, CA, USA, 2005. ACM Press.
[16]
Edsger W. Dijkstra. Go To statement considered harmful. Communications of the ACM, 11(3):147--148, March 1968.
[17]
Christopher Dutchyn, Paul Lu, Duane Szafron, Steven Bromling, and Wade Holst. Multi-dispatch in the Java Virtual Machine: Design and implementation. In USENIX, pages 6--6, San Antonio, Texas, United States, 2001. USENIX Association.
[18]
Johan Fabry and Tom Mens. Language-independent detection of object-oriented design patterns. Computer Languages, Systems and Structures, 30(1--2):21--33, 2004.
[19]
Neal Feinberg. Dylan Programming: An Object-Oriented and Dynamic Language. Addison-Wesley, 1997.
[20]
Brian Foote, Ralph E. Johnson, and James Noble. Efficient multimethods in a single dispatch language. In ECOOP, volume 3586, pages 337--361. Springer-Verlag, 2005.
[21]
Erich Gamma, Richard Helm, Ralph E. Johnson, and John Vlissides. Design Patterns. AW, 1994.
[22]
Joseph (Yossi) Gil and Itay Maman. Micro patterns in Java code. In OOPSLA, pages 97--116, San Diego, CA, USA, 2005. ACM Press.
[23]
Jeffrey Hightower. The location stack: A layered model for location in ubiquitous computing. In Proceedings of the 4th IEEE Workshop on Mobile Computing Systems & Applications (WMCSA2002), pages 22--28, 2002.
[24]
David Hume. A Treatise of Human Nature. Printed for John Noon, London, 1739.
[25]
Daniel H. H. Ingalls. A simple technique for handling multiple polymorphism. In OOPSLA, pages 347--349, Portland, OR, USA, 1986. ACM Press.
[26]
Warwick Irwin. Understanding and Improving Object-Oriented Software Through Static Software Analysis. PhD thesis, University of Canterbury, Christchurch, New Zealand, 2007.
[27]
James Kempf, Warren Harris, Roy D'Souza, and Alan Snyder. Experience with CommonLoops. In OOPSLA, pages 214--226, Orlando, FL, USA, 1987. ACM Press.
[28]
Gregor Kiczales, John Lamping, Anurag Mendhekar, Chris Maeda, Cristina Lopes, Jean-Marc Loingtier, and John Irwin. Aspectoriented programming. In ECOOP, volume 1241, pages 220--242. Springer-Verlag, 1997.
[29]
Gregor Kiczales, Erik Hilsdale, Jim Hugunin, Mik Kersten, Jeffrey Palm, and William G. Griswold. An overview of AspectJ. In ECOOP, volume 2072, pages 327--355. Springer-Verlag, 2001.
[30]
Eric Kidd. Efficient compression of generic function dispatch tables. Technical Report TR2001-404, Hanover, NH, USA, 2001.
[31]
David B. Lamkins and Richard P. Gabriel. Successful Lisp: How to Understand and Use Common Lisp. bookfix.com, 2005.
[32]
Gary T. Leavens and Todd Millstein. Multiple dispatch as dispatch on tuples. In OOPSLA, pages 274--287. ACM Press, 1998.
[33]
Kin-Keung Ma and Jeffrey S. Foster. Inferring aliasing and encapsulation properties for Java. In OOPSLA, pages 423--440, Montreal, Quebec, Canada, 2007. ACM Press.
[34]
Scott McKay and William York. Common Lisp Interface Manager: CLIM II Specification, 2001.
[35]
Hayden Melton and Ewan Tempero. An empirical study of cycles among classes in Java. Empirical Software Engineering, 12(4): 389--415, August 2007.
[36]
Warwick Mugridge, John Hamer, and John Hosking. Multi-methods in a statically typed programming language. In ECOOP, volume 512, pages 147--155. Springer-Verlag, 1991.
[37]
Jens Palsberg and J. Van Drunen. Visitor-oriented programming. In FOOL, Venice, Italy, 2004.
[38]
Alex Potanin, James Noble,Marcus Frean, and Robert Biddle. Scalefree geometry in object-oriented programs. Communications of the ACM, May 2005.
[39]
Qualitas Research Group. Qualitas corpus release 20080603. http://www.cs.auckland.ac.nz/Üewan/corpus/ The University of Auckland, June 2008.
[40]
Lee Salzman and Jonathan Aldrich. Prototypes with multiple dispatch: An expressive and dynamic object model. In ECOOP, volume 3586, pages 312--336, Glasgow, Scotland, 2005. Springer-Verlag.
[41]
Christopher Unkel and Monica S. Lam. Automatic inference of stationary fields: a generalization of Java's final fields. In POPL, volume 43, pages 183--195, New York, NY, USA, 2008. ACM Press.
[42]
Philip Wadler. The expression problem. Discussion on the Java-Genericity mailing list (see 12 November 1998 post), November 1998.
[43]
Matthias Zenger and Martin Odersky. Independently extensible solutions to the expression problem. In FOOL, San Diego, USA, October 2005. Also available as Technical Report IC/2004/109, EPFL, Switzerland, December 2004.

Cited By

View all
  • (2023)DataCurator.jl: efficient, portable and reproducible validation, curation and transformation of large heterogeneous datasets using human-readable recipes compiled into machine-verifiable templatesBioinformatics Advances10.1093/bioadv/vbad0683:1Online publication date: 1-Jun-2023
  • (2021)Pattern Matching Based on Object GraphsIEEE Access10.1109/ACCESS.2021.31285759(159313-159325)Online publication date: 2021
  • (2020)Towards an order-aware object comparisonProceedings of the 24th Brazilian Symposium on Context-Oriented Programming and Advanced Modularity10.1145/3427081.3427090(64-71)Online publication date: 19-Oct-2020
  • Show More Cited By

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM SIGPLAN Notices
ACM SIGPLAN Notices  Volume 43, Issue 10
September 2008
613 pages
ISSN:0362-1340
EISSN:1558-1160
DOI:10.1145/1449955
Issue’s Table of Contents
  • cover image ACM Conferences
    OOPSLA '08: Proceedings of the 23rd ACM SIGPLAN conference on Object-oriented programming systems languages and applications
    October 2008
    654 pages
    ISBN:9781605582153
    DOI:10.1145/1449764
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: 19 October 2008
Published in SIGPLAN Volume 43, Issue 10

Check for updates

Author Tags

  1. double dispatch
  2. empirical software engineering
  3. instanceof
  4. multimethods
  5. multiple dispatch

Qualifiers

  • Research-article

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)8
  • Downloads (Last 6 weeks)1
Reflects downloads up to 15 Feb 2025

Other Metrics

Citations

Cited By

View all
  • (2023)DataCurator.jl: efficient, portable and reproducible validation, curation and transformation of large heterogeneous datasets using human-readable recipes compiled into machine-verifiable templatesBioinformatics Advances10.1093/bioadv/vbad0683:1Online publication date: 1-Jun-2023
  • (2021)Pattern Matching Based on Object GraphsIEEE Access10.1109/ACCESS.2021.31285759(159313-159325)Online publication date: 2021
  • (2020)Towards an order-aware object comparisonProceedings of the 24th Brazilian Symposium on Context-Oriented Programming and Advanced Modularity10.1145/3427081.3427090(64-71)Online publication date: 19-Oct-2020
  • (2023)Julia language features for processing statistical dataDiscrete and Continuous Models and Applied Computational Science10.22363/2658-4670-2023-31-1-5-2631:1(5-26)Online publication date: 30-Mar-2023
  • (2022)Implementation of hyperbolic complex numbers in Julia languageDiscrete and Continuous Models and Applied Computational Science10.22363/2658-4670-2022-30-4-318-32930:4(318-329)Online publication date: 26-Dec-2022
  • (2021)Taming the Merge OperatorJournal of Functional Programming10.1017/S095679682100018631Online publication date: 2-Nov-2021
  • (2020)TileCode: Creation of Video Games on Gaming HandheldsProceedings of the 33rd Annual ACM Symposium on User Interface Software and Technology10.1145/3379337.3415839(1182-1193)Online publication date: 20-Oct-2020
  • (2020)A Simple Model for Reasoning about Limits on Coupling in Object-Oriented Software2020 10th Annual Computing and Communication Workshop and Conference (CCWC)10.1109/CCWC47524.2020.9031128(0163-0168)Online publication date: Jan-2020
  • (2018)Julia: dynamism and performance reconciled by designProceedings of the ACM on Programming Languages10.1145/32764902:OOPSLA(1-23)Online publication date: 24-Oct-2018
  • (2016)Antipattern and Code Smell False Positives: Preliminary Conceptualization and Classification2016 IEEE 23rd International Conference on Software Analysis, Evolution, and Reengineering (SANER)10.1109/SANER.2016.84(609-613)Online publication date: Mar-2016
  • Show More Cited By

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Figures

Tables

Media

Share

Share

Share this Publication link

Share on social media