Questions tagged [multiple-dispatch]
8 questions
18
votes
1 answer
Multiple Dispatch vs. Function Overloading
I'm trying to understand the difference (if any) between the two.
According to the Wikipedia page for Multiple Dispatch it is synonymous with Function Overloading, but then later on goes on to say:
In a language with only single dispatch, such as…

KaptajnKold
- 933
- 1
- 6
- 12
7
votes
1 answer
How to tackle extensibility considering the Data/Object Anti-Symmetry?
In Clean Code by Uncle Bob, page 124-125 he states
Procedural code (code using data structures) makes it easy to add new functions without changing the existing data structures. OO code, on the other hand, makes it easy to add new classes without…

Jp_
- 189
- 5
7
votes
3 answers
Understanding Multiple Dispatch
I've been reading around trying to understand multiple dispatching, and why it's so special.
On Wikipedia I came across this simple example:
(defmethod collide-with ((x asteroid) (y asteroid))
;; deal with asteroid hitting asteroid
)
…

Electric Coffee
- 1,465
- 1
- 14
- 22
2
votes
2 answers
How would dispatch work in the Wizards and Warriors "rulebook"?
In Part 5 of Wizards and Warriors, the blog proposes the concept of a "Rule" and rulebook to address the issues with solutions in the previous parts.
One of the issues was the need for double dispatch using a Visitor pattern:
Player player = new…

justin
- 49
- 3
2
votes
2 answers
Are multiple dynamic dispatch methods possible?
C++ only supports single dynamic dispatch methods. Indeed, the following program:
#include
struct Shape {
virtual void overlap(Shape* y) { std::cout << "Shape, Shape\n"; }
};
struct Circle: Shape {
void overlap(Shape* y) { std::cout…

Géry Ogam
- 602
- 3
- 13
2
votes
2 answers
Strategy for implementing Multiple Dispatch
This is a question regarding how Multiple Dispatch works.
Suppose that we have a type hierarchy like this:
Drawable -> Shape -> Polygon -> Rectangle
And there are three functions (This is a pseudo-code):
void func(Rectangle*, Drawable*, Drawable*)…

Mahdi
- 179
- 5
0
votes
1 answer
Any tradeoffs for using open methods?
I was trying to understand the use of multi-methods recently and saw several claims that they solve the Expression Problem. However, I ended concluding that it is not the multi-methods that solve it, but the open methods, which usually accompany the…

Nemanja
- 119
- 2
0
votes
1 answer
Does this architectural design "smell" like Service Locator and can this be dealt with in a more robust manner?
I have an architecture based on a domain with multiple object types. These objects (many and of disparate types) must reside together with each other because they make up a use-case. The types are not more than 20-30, but might be added along the…

Vector Zita
- 2,372
- 8
- 19