Nothing Special   »   [go: up one dir, main page]

skip to main content
10.1145/1289971.1289993acmconferencesArticle/Chapter ViewAbstractPublication PagesgpceConference Proceedingsconference-collections
Article

Open multi-methods for c++

Published: 01 October 2007 Publication History

Abstract

Multiple dispatch - the selection of a function to be invoked based on the dynamic type of two or more arguments - is a solution to several classical problems in object-oriented programming. Open multi-methods generalize multiple dispatch towards open-class extensions, which improve separation of concerns and provisions for retroactive design. We present the rationale, design, implementation, and performance of a language feature, called open multi-methods, for C++. Our open multi-methods support both repeated and virtual inheritance. Our call resolution rules generalize both virtual function dispatch and overload resolution semantics. After using all information from argument types, these rules can resolve further ambiguities by using covariant return types. Great care was taken to integrate open multi-methods with existing C++ language features and rules. We describe a model implementation and compare its performance and space requirements to existing open multi-method extensions and workaround techniques for C++. Compared to these techniques, our approach is simpler to use, catches more user mistakes, and resolves more ambiguities through link-time analysis, runs significantly faster, and requires less memory. In particular, the runtime cost of calling an open multi method is constant and less than the cost of a double dispatch (two virtual function calls). Finally, we provide a sketch of a design for open multi-methods in the presence of dynamic loading and linking of libraries.

References

[1]
A. Alexandrescu. Modern C++ Design: Generic Programming and Design Patterns Applied. AW C++ in Depth Series. Addison Wesley, January 2001.
[2]
E. Amiel, O. Gruber, and E. Simon. Optimizing multi-method dispatch using compressed dispatch tables. In OOPSLA '94, pages 244--258, New York, NY, USA, 1994. ACM Press.
[3]
K. Arnold, J. Gosling, and D. Holmes. The Java Programming Language, 3rd edition. Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA, 2000.
[4]
M. H. Austern. Generic programming and the STL: using and extending the C++ Standard Template Library. Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA, 1998.
[5]
L. Bettini, S. Capecchi, and B. Venneri. Double dispatch in C++. Software - Practice and Experience, 36(6):581--613, 2006.
[6]
G. M. Birtwistle, O. Dahl, B. Myhrhaug, and K. Nygaard. Simula BEGIN. Auerbach Press, Philadelphia, 1973.
[7]
J. Boyland and G. Castagna. Parasitic methods: an implementation of multi-methods for Java. In OOPSLA '97, pages 66--76, New York, NY, USA, 1997. ACM Press.
[8]
K. Bruce, L. Cardelli, G. Castagna, G. T. Leavens, and B. Pierce. On binary methods. Theor. Pract. Object Syst., 1(3):221--242, 1995.
[9]
C. Chambers. Object-oriented multi-methods in Cecil. In ECOOP '92, pages 33--56, London, UK, 1992. Springer-Verlag.
[10]
C. Chambers. The Cecil language: Specification and rationale. 3.2. Technical report, Department of Computer Science and Engineering. University of Washington, 2004.
[11]
C. Chambers and W. Chen. Efficient multiple and predicated dispatching. In OOPSLA '99, pages 238--255, New York, NY, USA, 1999. ACM Press.
[12]
C. Clifton, G. T. Leavens, C. Chambers, and T. Millstein. MultiJava: modular open classes and symmetric multiple dispatch for Java. In OOPSLA '00, pages 130--145, New York, NY, USA, 2000. ACM Press.
[13]
Codesourcery.com. The Itanium C++ ABI. Technical report, 2001.
[14]
T. H. Cormen, C. E. Leiserson, R. L. Rivest, and C. Stein. Introduction to algorithms. MIT Press, Cambridge, MA, USA, 2001.
[15]
Edison Design Group. C++ Front End, March 2006.
[16]
C. B. Flynn and D. Wonnacott. Reconciling encapsulation and dynamic dispatch via accessory functions. Technical Report 387, Rutgers University Department of Computer Science, 1999.
[17]
B. Foote, R. Johnson, and J. Noble. Efficient Multimethods in a Single Dispatch Language. Proceedings of the European Conference on Object-Oriented Programming, Glasgow, Scotland, July, 2005.
[18]
E. Gamma, R. Helm, R. Johnson, and J. Vlissides. Design patterns: Elements of reusable object-oriented software. Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA, 1995.
[19]
M. Gibbs and B. Stroustrup. Fast dynamic casting. Softw. Pract. Exper., 36(2):139--156, 2006.
[20]
A. Goldberg and D. Robson. Smalltalk-80: the language and its implementation. Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA, 1983.
[21]
D. Gregor, J. Jarvi, J. Siek, B. Stroustrup, G. D. Reis, and A. Lumsdaine. Concepts: Linguistic support for generic programming. OOPSLA'06, 2006.
[22]
International Organization for Standardization. ISO/IEC 10918-1:1994: Information technology - Digital compression and coding of continuous-tone still images: Requirements and guidelines. 1994.
[23]
ISO/IEC 14882 International Standard. Programming languages C++. American National Standards Institute, September 1998.
[24]
B. Liskov. Keynote address - data abstraction and hierarchy. In OOPSLA '87, pages 17--34, New York, NY, USA, 1987. ACM Press.
[25]
Lockheed Martin. Joint Strike Fighter, Air Vehicle, C++ Coding Standard. Lockheed Martin, December 2005.
[26]
B. Meyer. Eiffel: The Language. Prentice-Hall, Inc., Upper Saddle River, NJ, USA, 1992.
[27]
T. Millstein, M. Reay, and C. Chambers. Relaxed MultiJava: balancing extensibility and modular typechecking. In OOPSLA '03, pages 224--240, New York, NY, USA, 2003. ACM Press.
[28]
T. D. Millstein and C. Chambers. Modular statically typed multimethods. In ECOOP '99, volume 1628 of LNCS, pages 279--303, London, UK, 1999. Springer-Verlag.
[29]
M. Schordan and D. Quinlan. A source-to-source architecture for user-defined optimizations. In JMLC'03, volume 2789 of LNCS, pages 214--223. Springer-Verlag, August 2003.
[30]
A. Shalit. The Dylan Reference Manual. 2nd edition. Apple Press, 1996.
[31]
J. Smith. Draft proposal for adding multimethods to C++. Technical Report N1463, JTC1/SC22/WG21 C++ Standards Committee, 2003.
[32]
G. L. Steele Jr. Common LISP: the language (2nd ed.). Digital Press, Newton, MA, USA, 1990.
[33]
B. Stroustrup. The design and evolution of C++. ACM Press/Addison-Wesley Publishing Co., New York, NY, USA, 1994.
[34]
B. Stroustrup. The C++ Programming Language. Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA, 2000.
[35]
B. Stroustrup and G. Dos Reis. Supporting SELL for high-performance computing. In LCPC'05, volume 4339 of LNCS, pages 458--465. Springer-Verlag, October 2005.
[36]
G. van Rossum. The Python Language Reference Manual. Network Theory Ltd., September 2003.
[37]
J. Visser. Visitor combination and traversal control. In OOPSLA '01, pages 270--282, New York, NY, USA, 2001. ACM Press.
[38]
D. Wasserrab, T. Nipkow, G. Snelting, and F. Tip. An operational semantics and type safety proof for multiple inheritance in C++. In OOPSLA '06, pages 345--362, New York, NY, USA, 2006. ACM Press.
[39]
D. Wonnacott. Using accessory functions to generalize dynamic dispatch in single-dispatch object-oriented languages. In COOTS, pages 93--102. USENIX COOTS, 2001.
[40]
A. Wöß, M. Löberbauer, and H. Mössenböck. LL(1) conflict resolution in a recursive descent compiler generator. In JMLC'03, volume 2789 of LNCS, pages 192--201. Springer-Verlag, 2003.
[41]
www.fourcc.org. Video codec and pixel format definition, February 2007.

Cited By

View all
  • (2018)Exploration of modularity and reusability of domain-specific languagesComputer Languages, Systems and Structures10.1016/j.cl.2017.07.00451:C(48-70)Online publication date: 1-Jan-2018
  • (2014)KorzProceedings of the 2014 ACM International Symposium on New Ideas, New Paradigms, and Reflections on Programming & Software10.1145/2661136.2661147(113-131)Online publication date: 20-Oct-2014
  • (2014)Scoping rules on a platterProceedings of the 10th ACM SIGPLAN workshop on Generic programming10.1145/2633628.2633633(59-70)Online publication date: 26-Aug-2014
  • Show More Cited By

Recommendations

Comments

Please enable JavaScript to view thecomments powered by Disqus.

Information & Contributors

Information

Published In

cover image ACM Conferences
GPCE '07: Proceedings of the 6th international conference on Generative programming and component engineering
October 2007
206 pages
ISBN:9781595938558
DOI:10.1145/1289971
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]

Sponsors

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 01 October 2007

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. C++
  2. generic programming
  3. multi-methods
  4. multiple dispatch
  5. object oriented programming
  6. open-methods

Qualifiers

  • Article

Conference

GPCE '07

Acceptance Rates

Overall Acceptance Rate 56 of 180 submissions, 31%

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)8
  • Downloads (Last 6 weeks)1
Reflects downloads up to 20 Nov 2024

Other Metrics

Citations

Cited By

View all
  • (2018)Exploration of modularity and reusability of domain-specific languagesComputer Languages, Systems and Structures10.1016/j.cl.2017.07.00451:C(48-70)Online publication date: 1-Jan-2018
  • (2014)KorzProceedings of the 2014 ACM International Symposium on New Ideas, New Paradigms, and Reflections on Programming & Software10.1145/2661136.2661147(113-131)Online publication date: 20-Oct-2014
  • (2014)Scoping rules on a platterProceedings of the 10th ACM SIGPLAN workshop on Generic programming10.1145/2633628.2633633(59-70)Online publication date: 26-Aug-2014
  • (2013)Open pattern matching for C++ACM SIGPLAN Notices10.1145/2637365.251722249:3(33-42)Online publication date: 27-Oct-2013
  • (2013)Open pattern matching for C++Proceedings of the 12th international conference on Generative programming: concepts & experiences10.1145/2517208.2517222(33-42)Online publication date: 27-Oct-2013
  • (2013)Open pattern matching for C++Proceedings of the 2013 companion publication for conference on Systems, programming, & applications: software for humanity10.1145/2508075.2508098(97-98)Online publication date: 26-Oct-2013
  • (2011)JavaGIACM Transactions on Programming Languages and Systems (TOPLAS)10.1145/1985342.198534333:4(1-83)Online publication date: 1-Jul-2011
  • (2010)Checking structural integrity for metadata repository systems by means of description logicsProceedings of the 15th international conference on Database systems for advanced applications10.5555/1880853.1880869(118-129)Online publication date: 1-Apr-2010
  • (2010)Checking Structural Integrity for Metadata Repository Systems by Means of Description LogicsDatabase Systems for Advanced Applications10.1007/978-3-642-14589-6_13(118-129)Online publication date: 2010
  • (2009)CZProceedings of the 24th ACM SIGPLAN conference on Object oriented programming systems languages and applications10.1145/1640089.1640092(21-40)Online publication date: 26-Oct-2009
  • 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

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media