
Looking for a math.probability newsgroup
Quote:
> Did somebody ever write a paper on this subject?
> I would like to answer questions about the advantages of possibly having
> dispatching on several parameters in a primitive operation (Ada) vs having
> single dispatching on the implicit "this" parameter of a method (C++).
Actually, in Ada, you can only dispatch on one type... it's the same model
as C++, with a different 'look'... for example, where in C++ you would write
obj.foo (x), in Ada you would write foo (obj, x).
A standard C++ trick which can also be used in Ada to re-dispatch, thereby
gaining something that looks like dispatch on multiple parameters goes
something like this:
class B;
class A {
public:
A () { }
foo (B *q, int loop) {
if (!loop)
// Redispatch based on specific type of B, with 'this'
q->foo (this, 1);
else {
// handle it
}
}
};
class B {
public:
B () { }
foo (A *q, int loop) {
if (!loop)
// Redispatch based on specific type of A, with 'this'
q->foo (this, 1);
else {
// handle it
}
}
};
then, if you derive classes from A & B, and pass them around as A* or B*,
you can still get the most specific method which applies to the most specific
type of A & B for which the method exists, by going back & forth until
either you loop, or until some method handles it.
- Vladimir