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
3
votes
1 answer

Is it accurate to describe dispatch in Clojure using a Protocol as 'static'?

Meikel Brandmeyer wrote a post on dispatch in Clojure with the URL title Static vs Dynamic. He writes: Protocols are not the only place where we have a trade-off of static vs. dynamic. There are several places where such a trade-off can be…
hawkeye
  • 34,745
  • 30
  • 150
  • 304
3
votes
2 answers

Is is possible to do an end-run around generics covariance in C# < 4 in this hypothetical situation?

Suppose I have a small inheritance hierarchy of Animals: public interface IAnimal { string Speak(); } public class Animal : IAnimal { public Animal() {} public string Speak() { return "[Animal] Growl!"; } } public class Ape…
John Feminella
  • 303,634
  • 46
  • 339
  • 357
3
votes
4 answers

How to stop dispatch_queue in ios?

I want to know the way for stopping asyncronous task when i click back button in navigation bar.I have done this code,but its not working ... dispatch_group_t imageQueue = dispatch_group_create(); dispatch_group_async(imageQueue,…
user3441799
3
votes
0 answers

When should one use multiple DispatcherServlets in Spring MVC?

Spring MVC allows for multiple DispatcherServlets. However, I can't find single case when using multiple DispatcherServlets is more useful than single instance. Could you provide a scenario in which multiple DispatcherServlets have advantage over…
Marcin Szymczak
  • 11,199
  • 5
  • 55
  • 63
3
votes
4 answers

How does an OS or a systems program wait for user input?

I come from the world of web programming and usually the server sets a superglobal variable through the specified method (get, post, etc) that makes available the data a user inputs into a field. Another way is to use AJAX to register a callback…
Cian E
  • 1,079
  • 1
  • 8
  • 9
3
votes
5 answers

C# method overload with inheritance

I always thought C# resolves method calls dynamically during runtime by looking at the runtime type of the method call receiver (i.e. the object before the dot). However the following code sample works differently. If I use GenericSpaceShip in the…
3
votes
1 answer

C++ Double Dispatch, Factory Pattern or a way to automate creating derived objects from received serial data

I'm working on a C++ communication library in which I receive serialized data from a number of devices (network sockets, uart/usb, CAN, and LIN networks). I also need to create serialized data from my message objects. I have a base class called…
Eric
  • 1,697
  • 5
  • 29
  • 39
3
votes
3 answers

Double dispatch for collision handling with SpriteKit

I'm using SpriteKit's collision detection. It has a callback that looks like this: - (void)didBeginContact:(SKPhysicsContact *)contact The contact object has two physics bodies: SKPhysicsBody *bodyA; SKPhysicsBody *bodyB; My game will have lots of…
nont
  • 9,322
  • 7
  • 62
  • 82
3
votes
4 answers

How can I create a type based lookup table in order to implement multiple-dispatch in C++?

I'm attempting to make a messaging system in which any class derived from "Messageable" can receive messages based on how the function handleMessage() is overloaded. For example: class Messageable { public: void takeMessage(Message&…
Jake Woods
  • 1,808
  • 15
  • 20
3
votes
3 answers

How Does the JVM handle Dynamic Dispatch in this Situation?

Given the following source and ouput: Source: public class A { public void foo() { bar(); } public void bar() { System.out.println ("in A's bar() method"); } } public class B extends A { @Override public void foo() { …
user711807
3
votes
1 answer

dispatch a S4 method over the slot of a S4 class

I would like to create a S4 method 'myMethod' that dispatches not only on the class of the first argument of the function, but also on the value of one of the slot of this class. for instance myObject: @slot1="A" @... I would like…
RockScience
  • 17,932
  • 26
  • 89
  • 125
3
votes
2 answers

jQuery dispatch event from a plugin for multiple listeners

I'm looking for a way to dispatch an event from my jQuery plugin so that it can have multiple listeners for that event. I have the plugin setup so that it returns a reference to itself so that I can add listeners later via public methods. The only…
DEfusion
  • 5,533
  • 5
  • 44
  • 60
3
votes
3 answers

Java parameter confusion

In the code below why is it that o1.equals(o2); calls equals(Object o) not the equals(EqualsTest et) even though o1 and o2 are referencing objects of type EqualsTest! public class EqualsTest { public static boolean equalTest(T o1, T o2) { …
user133466
  • 3,391
  • 18
  • 63
  • 92
3
votes
1 answer

Magento: Stop dispatching in pre_dispatch observer

I want to influence product rendering (passing $params to Mage_Catalog_Helper_Product_View::prepareAndRender()) and registered an observer on the controller_action_predispatch_catalog_product_viewevent. rendering is working fine, but the original…
Alex
  • 32,506
  • 16
  • 106
  • 171
3
votes
2 answers

In RubyMotion how do you cancel a list refresh when the back link is touched?

I'm new to RubyMotion and struggling to get to grips with some of the APIs. My app is a very basic series of UITable lists, if you select an item you go into the list for that item which is achieved by pushing a new controller. This all works fine,…