February 10, 2005
> For multi-dispatch, I cannot see any way to do that. If you have any pointers about it, I would personally be very interested.

I am currently developing a simulation engine for DoD modeling and simulations.  The simulation engine uses a template for two dimensional multimethods.  The multimethods are used to describe relationships between different kinds of objects in the simulation.  It requires that each type be enumerated.  This is difficult to do using C++ RTTI, so I use my own type system.  Once each type is enumerated, O(1) algorithms are possible.  The simplest way to do this is with an N-Dimensional array of methods.  Since each type's enumerated value will be its index into the array.  Each multimethod must have its own array.  The number of dimensions will correspond to the number of virtual parameters.

It is easy to see why this method is so fast.  It is simply indexing a lookup table.  The problem is that these arrays can become considerably large, especially as the number of virtual parameters increases.  For this reason, my currently implementation is limited to two dimensions.  However, there are algorithms that compress the lookup tables and still retain the O(1) performance.  The drawback is that this approach is considerably more complex and difficult to implement.

> As for the design of D: it clearly is a difficult decision which features
> a
> language should support. Every programmer has some favorite programming
> style that depends on certain features in the language. Supporting
> everything is impossible and would lead to a cluttered language. Whether
> multimethods are important enough to include them is a matter of
> investigation. In any case, I would really want to see some real-world
> example that inherently depends on multimethods.

Well my vote is to include multimethods natively.

I suppose that a first step to providing high-performance multimethods in D is providing enumeration values for the types.  They would have to be enumerated from each base class.  Thus if B inherits A and C inherits B, C would have two enumerations:  one with base A and another with base B.  (If I'm confusing you just let me know and I will expound some more.)  This would allow for high-performance multimethod libraries to be written.  The next step would be to add the keywords and syntax sugar that replaces those libraries.


Next ›   Last »
1 2
Top | Discussion index | About this forum | D home