Questions tagged [dispatch]
9 questions
10
votes
5 answers
Dynamic dispatch from a string (Python)
Lets assume I have a string for a class name (or part of a class name), and I have implementation somewhere. All I want, is to be able to get an instance of a class with the name in the variable.
For example,
dynamic_class_name = "Circle" # not a…
Roman Susi
- 1,803
4
votes
5 answers
Dynamic dispatch overuse
I was going through old code and noticed one pattern that repeats itself all over the place - dynamic dispatch.
While I don't see any problem with the implementation itself, I was wondering if there are other ways of handling dynamic dispatch.
To…
Michael
- 183
3
votes
1 answer
A real-world use case for triple dispatch
A few times in my career I've encountered design problems that couldn't be elegantly solved with single dispatch and required double dispatch (which I implemented using visitors). However, I've never encountered a problem that required triple…
Alexey
- 277
2
votes
0 answers
How to dispatch these functions in Objective C to not lock Main thread?
There's a large shared object (kind of OpenGL context) in my project.
It is accessed from multiple threads.
To ensure only one thread at the moments is using SHARED_OBJECT, mutex (kind of NSRecursiveLock) is used.
The problem is that sometimes…
olha
- 179
2
votes
2 answers
Is it possible to have Ad-Hoc polymorphism with runtime dispatch?
As I did understand, and as it's described here, ad-hoc polymorphism is limited to compile-time dispatch. That is, if we have a function that expects an argument that belongs to a typeclass, we must know the concrete type of the argument at compile…
Display Name
- 265
2
votes
1 answer
Differences between Dynamic Dispatch and Dynamic Binding
I've been looking on Google for a clear diffrentiation with examples but couldn't find any.
I'm trying to understand the differences between Dynamic Dispatch and Dynamic Binding in Object Oriented languages.
As far as I understand, Dynamic Dispatch…
Aviv Cohn
- 21,538
1
vote
2 answers
Message Dispatching: If, Visitor, or something else
I often write code to implement the dispatching and handling of "messages." My requirements are usually:
I should be able to add new types of messages AND/OR new types of handlers without affecting the existing messages or handlers (i.e., loose…
Patrick Wright
- 789
- 4
- 12
0
votes
0 answers
value-based function dispatch
Problem to solve
I have a method parse_doc that should dynamically determine a parsing function to parse document_id based on the value of the document_id string:
# list of files that may have different custom parser that depends arbitrarily on…
anon01
- 117
- 4
0
votes
1 answer
Type selection from a dispatcher table
I am trying to use a dispatch table to select a data type to cast something as and cannot figure out the syntax for this.
g_cast_table[] =
{
{'h', short int}
or
{'h', "short int"}
}
outcome: (short int)q
Right now my table is set…
M. Sharpe
- 11