Questions tagged [dispatch]

Dynamic dispatch (also known as dynamic binding) is the process of mapping a message to a specific sequence of code (method) at runtime. This is done to support the cases where the appropriate method cannot be determined at compile-time (i.e. statically).

Dynamic dispatch is only used for code invocation and not for other binding processes (such as for global variables) and the name is normally only used to describe a language feature where a runtime decision is required to determine which code to invoke.

This Object-Oriented feature allows substituting a particular implementation using the same interface, and therefore it enables polymorphism.

http://en.wikipedia.org/wiki/Dynamic_dispatch

974 questions
6
votes
1 answer

Callwith not calling other candidates? What are "other candidates"? Is it exhausting the list of other candidates? Is that list available?

I'm trying to address this issue, which was actually raised by this other stackoverflow question related to the different behavior of callwith and samewith. The latter seems to be clearly defined, however, it's not so clear with callwith. Check out…
jjmerelo
  • 22,578
  • 8
  • 40
  • 86
6
votes
3 answers

How to select which overloaded version of a method to call without using a cast?

i have a question to Java Overload Methods. Suppose i have an overload methods foo: public static String foo(String x) { return "foo-String: " + x; } public static String foo(Object x) { return "foo-Object: " + x; } How can I implement to…
Aiko West
  • 791
  • 1
  • 10
  • 30
6
votes
1 answer

Wrong specialized generic function gets called in Swift 3 from an indirect call

I have code that follows the general design of: protocol DispatchType {} class DispatchType1: DispatchType {} class DispatchType2: DispatchType {} func doBar(value:D) { print("general function called") } func…
Abe Schneider
  • 977
  • 1
  • 11
  • 23
6
votes
4 answers

dispatch design pattern?

Suppose I have a class hierarchy in Java: interface Item { ... }; class MusicBox implements Item { ... }; class TypeWriter implements Item { ... }; class SoccerBall implements Item { ... }; and I have another class in the same package: class…
Jason S
  • 184,598
  • 164
  • 608
  • 970
6
votes
2 answers

Using a Common Lisp user-defined type in defmethod

I'd like to be able to use a defined type as a parameter specializer to a defmethod. The motivation is readability and flexibility to change at a later stage. Somehting like this: (deftype foo () 'fixnum) (defmethod bar ((x foo)) ...) (defmethod…
user3414663
  • 531
  • 3
  • 11
6
votes
0 answers

How can I get the count of elements in a dispatch_queue

I have created a dispatch queue for sending network data, such as messages or pictures. One block is for sending one message or picture. And put them in the dispatch queue. When the socket did send a message or picture, I Want to check how many…
singkeam86
  • 71
  • 3
6
votes
3 answers

How can I implement a dynamic dispatch table in C

First of all, I understand how to implement a dispatch table using function pointers and a string or other lookup, that's not the challenge. What I'm looking for is some way to dynamically add entries to this table at compile time. The type of code…
Dave Durbin
  • 3,562
  • 23
  • 33
5
votes
2 answers

Is dispatch_sync(dispatch_get_global_queue(xxx), task) sync or async

As Apple's document says, dispatch_get_global_queue() is a concurrent queue, and dispatch_sync is something meaning serial.Then the tasks are processed async or sync?
keywind
  • 1,135
  • 14
  • 24
5
votes
1 answer

chrome dispatching wheel event

I'm trying to dispatch a wheel event in chrome but still can't make it. I am using the WheelEvent object but seems that just cannot "init" it right. Whatever I do, delta is always 0. I looked at the specification, but no help. More interesting, I…
zpavlinovic
  • 1,507
  • 1
  • 17
  • 36
5
votes
1 answer

React context API- How i can dispatch an action from the useEffect hook?

In this project I'm using React.createContext() methode to manage the state. I can access to the state data by importing the Context.Consumer and using this consumer in the return methode of the class component(or functional component). See thie…
bilalo
  • 129
  • 1
  • 1
  • 7
5
votes
1 answer

Rust: polymorphic calls for structs in a vector

I'm a complete newbie in Rust and I'm trying to get some understanding of the basics of the language. Consider the following trait trait Function { fn value(&self, arg: &[f64]) -> f64; } and two structs implementing it: struct Add {} struct…
Gabriele
  • 469
  • 4
  • 10
5
votes
2 answers

Is there a way to create and dispatch/trigger custom event with react-navigation?

With DOM, you can easily create a trigger custom event with Javascript like so: var event = new Event('build'); // Listen for the event. elem.addEventListener('build', function (e) { /* ... */ }, false); // Dispatch the…
Monero Jeanniton
  • 441
  • 8
  • 20
5
votes
2 answers

Julia: Same function for multiple types?

I have this big function that I defined on a vector, but I'd like it to work also with a single value. I'd like the type of the first argument to be either a vector or a number. I triend the following: function bigfunction(x::Vector,…
Dominique Makowski
  • 1,511
  • 1
  • 13
  • 30
5
votes
1 answer

How do I do dispatch on value in julia?

I have heard julia has dispatch on values for symbols, and so I use Val{:MySymbol}. But this doesn't seem to work: julia> foo(x) = "other" foo (generic function with 1 method) julia> foo(x::Val{:zinger}) = "It was zinger" foo (generic function…
Frames Catherine White
  • 27,368
  • 21
  • 87
  • 137
5
votes
2 answers

Laravel 5.5 Queue Dispatch Not Working

Maybe I'm not understanding on Laravel queue works, or maybe it itself is not working, my expected behaviour for Laravel Queue/Dispatch is that if a dispatch is initiated from the Controller, the code dispatched to queue should be executed silently…
stoneferry
  • 177
  • 1
  • 2
  • 11