Questions tagged [dispatch]

8 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,763
  • 2
  • 12
  • 20
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
  • 1
  • 5
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
  • 237
  • 1
  • 4
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
  • 5
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
  • 1
  • 10
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,190
  • 31
  • 118
  • 178
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…
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…