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();
The method call will be performed according to the runtime type of mything
, namely Cat
.
This is the single dispatch capability (which is present in Java/C#).
Now, if you need to dispatch not only on the runtime type of receiver, but on the types of (multiple) arguments either, you face a little problem:
public class MyAcceptor {
public void accept (IVisitor vst) {...}
public void accept (EnhancedConcreteVisitor vst) {...}
}
The second method never gets called, because in our 'consumer' code we just tend to treat different types of objects (visitors in my example) by their common supertype or interface.
That's why I ask - because dynamic typing allows the multiple dispatch polymorphism and C# 4.0 has that dynamic keyword ;)