C++ Books

Friday, September 21, 2007

Open Multi-Methods for C++

We've recently got our paper on multi-methods accepted to GPCE'07 and Peter will do a dry run of the presentation on Tuesday, September 25, 2007 at 16:00 in HRBB 302. Please stop by and give us your feedback. Thanks!


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 multimethod 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.

Technical report on this work can be found here

More information about Peter Pirkelbauer can be found on his webpage.

No comments: