Saturday, December 15, 2007

doublecpp (dynamic overloading in C++)

Doublecpp is a preprocessor for C++ that handles a new linguistic construct for defining branches of a multi-method. The "right'' branch of such a method will be selected dynamically at run-time according to the actual type of the object on which the method is invoked and to the actual type of the first argument: double dispatch.

This way, you will have dynamic overloading (but only on the first argument, for the other arguments standard static overloading will be adopted).

The home page of the project is http://doublecpp.sourceforge.net. And the documentation can be found on-line at this link.

Doublecpp is based on our research on formalization and implementation of dynamic overloading in languages providing only static overloading. In particular, doublecpp will take as input a program written in C++ extended with the linguistic construct for dynamic overloading and will produce in output a standard C++ program with the same semantics.

The idea of the translation is based on the Visitor pattern, but it does not require the programmer to manually implement such pattern; furthermore, it performs all the type checks to assure type safety; thus, it is not merely an automatic implementation of this pattern.

Such implementation avoids down-casts and it is efficient since it uses dynamic binding twice, i.e., dynamic overloading takes place in constant time (other implementations rely on RTTI checks and require to inspect the class hierarchy, thus their complexity depends on the depth and width of the class hierarchy).

More importantly, our implementation of dynamic overloading is type safe: once the program is successfully compiled, no run-time errors (exceptions) will be raised during the execution of the program. Thus, all possible (static and dynamic) ambiguities are ruled out during the type checking.

The papers concerning this research are the following:

Translating Double-Dispatch into Single-Dispatch
Lorenzo Bettini, Sara Capecchi, Betti Venneri.
Proceedings of the Second Workshop on Object Oriented Developments (WOOD 2004). pp. 59-78. ENTCS vol. 138 no. 2. Elsevier. 2005. abstract doubledisp.pdf bibtex
Double Dispatch in C++
Lorenzo Bettini, Sara Capecchi, Betti Venneri.
Software - Practice and Experience. pp. 581 - 613. vol. 36 no. 6. 2006. abstract spelxb.ps.gz bibtex

1 comment:

Anonymous said...

Ciaoo...stò cercando di sviluppare un sito web-blog con forum in cui si parla di recensioni di film,game,serie tv e altro ancora...
sarei interessato ad uno scambio link con il tuo blog,che ne dici?
ti ringrazio anticipatamente e a presto
il sito è www.rapiditaliashare.com