Multi-methods and type switch
Hello, SoC2014 page on trac mentions interest for an implementation of type-switch for C++. For now, I have implemented a toy library for open multiple dispatch. It is based on compressed dispatch tables. It still just supports single inheritance and needs to attach integer tags to the dispatched class hierarchy. Is there any interest for further development of this library ? What would be the typical use cases ? Note : Although I opened with a reference to SoC2014, I do not intend to write a GSoC proposal for this work. Best regards, Camille Gillot
Em Qui, 2014-03-06 às 00:05 +0100, Camille GILLOT escreveu:
For now, I have implemented a toy library for open multiple dispatch. It is based on compressed dispatch tables. It still just supports single inheritance and needs to attach integer tags to the dispatched class hierarchy.
You may be interested in read this Bjarne's paper on the subject[1], if I understood what you mean by "multiple dispatch" correctly. [1] http://www.stroustrup.com/multimethods.pdf -- Vinícius dos Santos Oliveira https://about.me/vinipsmaker
Actually, I have used this paper for the dispatch table generation. I also used the table compression method from [2]. [2] "Fast Algorithms for Compressed Multi-Method Dispatch Tables Generation" by Dujardin, Amiel, Simon For now, the library works as follows : - classes to be used must inherit a CRTP class defining the small integer tag - multimethods are declared out of class - multimethods definitions may be spread across several compilation units - at first call to the multimethod, the dispatch table is computed using the algorithms from [1] and [2] - subsequent calls use the memorized table Do you think this code may reach interest for inclusion in boost ? Of course, I plan to support multiple inheritance before any submission. Best regards, Camille Gillot Le mercredi 5 mars 2014 20:26:06 Vinícius dos Santos Oliveira a écrit :
Em Qui, 2014-03-06 às 00:05 +0100, Camille GILLOT escreveu:
For now, I have implemented a toy library for open multiple dispatch. It is based on compressed dispatch tables. It still just supports single inheritance and needs to attach integer tags to the dispatched class hierarchy.
You may be interested in read this Bjarne's paper on the subject[1], if I understood what you mean by "multiple dispatch" correctly.
Em Qui, 2014-03-06 às 12:51 +0100, Camille GILLOT escreveu:
Do you think this code may reach interest for inclusion in boost ?
Well, I'm not a boost developer and I'm not participating on the mailing list for a long time. I just wanted to possibly help you with info to improve your proposal, but looks like you already knew it. Let's wait for the reply of some real boost developers and good luck. =) -- Vinícius dos Santos Oliveira https://about.me/vinipsmaker
On 03/05/14 17:05, Camille GILLOT wrote:
Hello,
SoC2014 page on trac mentions interest for an implementation of type-switch for C++.
Could you please provide a link?
For now, I have implemented a toy library for open multiple dispatch. It is based on compressed dispatch tables. It still just supports single inheritance and needs to attach integer tags to the dispatched class hierarchy.
Could you please provide source code? What are these integar tags used for?
Is there any interest for further development of this library ? What would be the typical use cases ?
I remember reading somewhere it could be used in a gaming application to code what happens when, for example, to opposing space warships do battle in space. Another toy use case it to decide what happens when two animals meet. (e.g. Dog chase cat. Cat eats mouse,) Using your library, how would you code the predator_prey.cpp example shown here: http://svn.boost.org/svn/boost/sandbox/variadic_templates/libs/composite_sto... ?
Note : Although I opened with a reference to SoC2014, I do not intend to write a GSoC proposal for this work.
Best regards,
Camille Gillot
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Le jeudi 6 mars 2014 06:51:45 Larry Evans a écrit :
On 03/05/14 17:05, Camille GILLOT wrote:
Hello,
SoC2014 page on trac mentions interest for an implementation of type-switch for C++.
Could you please provide a link?
https://svn.boost.org/trac/boost/wiki/SoC2014
For now, I have implemented a toy library for open multiple dispatch. It is based on compressed dispatch tables. It still just supports single inheritance and needs to attach integer tags to the dispatched class hierarchy. Could you please provide source code? What are these integar tags used for?
Source code is at : https://github.com/cjgillot/rtti The code is still poorly documented, please excuse it for now. The integer tags are computed at load time for each registered class. Each hierarchy owns a integer counter starting from 0. During static initialization, each class in the hierarchy is given an id based on this counter. (When I mention a class hierarchy, I mean a set of class sharing a common base class)
Is there any interest for further development of this library ? What would be the typical use cases ?
I remember reading somewhere it could be used in a gaming application to code what happens when, for example, to opposing space warships do battle in space. Another toy use case it to decide what happens when two animals meet. (e.g. Dog chase cat. Cat eats mouse,)
Using your library, how would you code the predator_prey.cpp example shown here:
http://svn.boost.org/svn/boost/sandbox/variadic_templates/libs/composite_sto rage/sandbox/pack/predator_prey.cpp ?
https://github.com/cjgillot/rtti/blob/master/examples/predator_prey/predator... Best regards, Camille Gillot
participants (3)
-
Camille GILLOT
-
Larry Evans
-
Vinícius dos Santos Oliveira