multiple-dispatch

What's the difference between Polymorphism and Multiple Dispatch?

...or are they the same thing? I notice that each has its own Wikipedia entry: [1] [2], but I'm having trouble seeing how the concepts differ. Edit: And how does Overloading fit into all this? ...

Work around Java's static method dispatching without Double Dispatch/Visitor patterns

I am using a class Foo that provides these methods: String overloadedMethod(Object) String overloadedMethod(Goo) Since Java statically dispatches on the non-receiver argument, I cannot just pass my value (which is an Object, but might have dynamic type Goo) and rely on the JVM to dynamically choose the "correct" method. This is my cu...

Is C# a single dispatch or multiple dispatch language?

I'm trying to understand what single and multiple dispatch are, exactly. I just read this: http://en.wikipedia.org/wiki/Multiple_dispatch And from that definition is seems to me that C# and VB.Net are multiple-dispatch, even though the choice of which overload to call is made at compile-time. Am I correct here, or am I missing somethi...

What is - Single and Multiple Dispatch (in relation to .NET)?

Is it the same as overloading, if not, can you please provide and example of each in C# I have read the responses to a similar question asked in SO ... i did not understand the responses posted to it. Similar question asked here EDIT: With the new "dynamic" keyword in C# 4.0 ... would this make the language "multi dispatch" enabled? ...

Multiple dispatch in C++

Hi, I am trying to understand what multiple dispatch is. I read a lot of various texts but I still have no idea what multiple dispatch is and what it is good for. Maybe the thing I am missing is piece of code using multiple dispatch. Please, can you write a little piece of code in C++ using multiple dispatch so that I can see it cannot b...

Special interaction between derived objects (i.e. mutiple dispatch)

So, I have a list of base class pointers: list<Base*> stuff; Then, at some point one of the objects will look through all other objects. Base * obj = ...; // A pointer from the 'stuff'-list. for (list<Base*>::iterator it = stuff.begin(); it != stuff.end(); it++) { if (obj == *it) continue; // Problem scenario is here...

Virtual functions with two operands that can take many different types

Let me start with a concrete example. In C++, I have a hierarchy of classes under the abstract base class CollisionVolume. Any collision volume needs to be able to detectCollision with any other volume. This collision code is specialized based on the two subclasses in presence, but it is commutative: detectCollision(a, b) == detectCollis...

Optimizing multiple dispatch notification algorithm in C#?

Sorry about the title, I couldn't think of a better way to describe the problem. Basically, I'm trying to implement a collision system in a game. I want to be able to register a "collision handler" that handles any collision of two objects (given in either order) that can be cast to particular types. So if Player : Ship : Entity and Lase...

Does new 'dynamic' variable type in .NET 4.0 solve the single/multiple method dispatch issue in CLR?

The problem of single dispatch is mostly familiar to people engaged in coding with statically typed languages like Java and C#. The basic idea is: While the runtime polymorphism allows us to dispatch to the right method call according to the type (runtime type) of receiver, for example: IAnimal mything = new Cat(); mything.chop(); Th...

Apples, oranges, and pointers to the most derived c++ class

Suppose I have a bunch of fruit: class Fruit { ... }; class Apple : public Fruit { ... }; class Orange: public Fruit { ... }; And some polymorphic functions that operate on said fruit: void Eat(Fruit* f, Pesticide* p) { ... } void Eat(Apple* f, Pesticide* p) { ingest(f,p); } void Eat(Orange* f, Pesticide* p) { peel(f,p); ingest...

Why doesn't C++ allow you to request a pointer to the most derived class?

(This question should probably be answered with a reference to Stroustrup.) It seems extremely useful to be able to request a pointer to the most derived class, as in the following: class Base { ... }; class DerivedA { ... }; class DerivedB { ... }; class Processor { public: void Do(Base* b) {...} void Do(DerivedA* d) {...} voi...