Factbites
 Where results make sense
About us   |   Why use us?   |   Reviews   |   PR   |   Contact us  

Topic: Double dispatch


Related Topics

In the News (Sun 20 Dec 09)

  
  Efficient Multimethods in a Single Dispatch Language
Hence, triple dispatch is performed for three argument multimethods, quadruple dispatch for four, octuple dispatch for eight, etc. At each step, identified class/type information is “mangled” into the selectors, that is, we automatically generate the same code that a programmer would write to implement multiple dispatch in Smalltalk.
In general, we consider that an idiom — such as double dispatch — should be incorporated into a language when it becomes very widely used, when a hand coded implementation is hard to write or to modify, when it can be implemented routinely, and at least as efficiently as handwritten code.
We believe that multiple dispatch is sufficiently often used; sufficiently routine; sufficiently arduous to hand code; and that our (and others) implementations are sufficiently efficient for it to be worthwhile to include into object-oriented programming languages.
www.laputan.org /reflection/Foote-Johnson-Noble-ECOOP-2005.html   (6764 words)

  
  Double dispatch - Wikipedia, the free encyclopedia
In software engineering, double dispatch is a mechanism that dispatches a function call to different concrete functions depending on the runtime types of multiple objects involved in the call.
Double dispatch is useful in situations where the result of some computation depends on the runtime types of its arguments.
At first glance, double dispatch appears to be a natural result of function overloading.
en.wikipedia.org /wiki/Double_dispatch   (540 words)

  
 Double Dispatch   (Site not responding. Last check: 2007-10-18)
Double dispatching "solves" this problem by applying next logic: Since language determines what type the target of the call is dynamically, lets switch target and parameter and call a method on parameter.
Note that after double dispatch target and argument switch places, but it is a small problem.
Provide a common entry point: lets keep the old name commonMethod(arg1, arg2) and create a dispatch table there: this could be a switch statement or an implementation of vtable in C++ case with function pointers to commonMethod's, which could be retrieved by type names of arguments.
www.cs.purdue.edu /homes/bahmutov/cs510/double.html   (638 words)

  
 double dispatching
Double dispatching, as used in the Magnitude hierarchy, helps to avoid long methods that must test for type (class) of the objects handled.
Double dispatching is a way to do this without checking each type explicitly.
In more complicated scenarios with more types involved, you might get even triple or higher dispatching, but the trick is always the same, you leverage on the fact that you as the receiver of a message know YOUR type and send an appropriate "typed" message to the argument.
www.codecomments.com /message193780.html   (1986 words)

  
 Multi-Dispatch in the Java Virtual Machine: Design and Implementation
Double dispatch occurs when a method explicitly checks an argument type and executes different code as a result of this check.
Double dispatch is illustrated in Figure 2(a) (from Sun's AWT classes) where the
Another common use for double dispatch is in drag-and-drop applications, where the result of a user action depends on both the data object dragged and on the target object.
www.cs.ualberta.ca /~paullu/Papers/COOTS2001-HTML/mdj.html   (8431 words)

  
 Doublecpp - double dispatch in C++   (Site not responding. Last check: 2007-10-18)
Doublecpp is a preprocessor for C++ that handles a new linguistic construct for defining branches of a multi-method.
The "right'' branch of such a method will be selected dynamically at run-time according to the actual type of the object on which the method is invoked and to the actual type of the first argument: double dispatch.
Doublecpp is free software; you are free to use, share and modify it under the terms of the GNU General Public License (see COPYING).
doublecpp.sourceforge.net   (212 words)

  
 Single, Double And Multiple Dispatch « Abhijit Nadgouda @ iface
The dispatch in the nomenclature is about dispatching messages to objects, as it is said in Smalltalk.
In the single dispatch mechanism, the method to be invoked in determined using the object, usually type of the object, on which it is invoked.
It is in fact a simulation using the single dispatch mechanism, and hence is not completely extensible.
iface.wordpress.com /2006/07/29/single-double-and-multiple-dispatch   (556 words)

  
 1.1.11.1 Double Dispatch and the ``Visitor'' Pattern
Double dispatch and the ``Visitor'' pattern are mechanisms for selecting a method to be executed, based on the type of two objects at the same time.
The ``Visitor'' pattern is a specialized form of double dispatch, used to apply an algorithm to a structured collection of objects.
Like double dispatch, this pattern is definitely an improvement over writing large if-then-else blocks to introspect types.
peak.telecommunity.com /protocol_ref/dispatch-example.html   (974 words)

  
 COOTS 2001 Paper
Double dispatch is illustrated in Figure 2(a) (from Sun's AWT classes) where the
Another common use for double dispatch is in drag-and-drop applications, where the result of a user action depends on both the data object dragged and on the target object.
If a dispatcher has not been instantiated, and the just-loaded class is uni-dispatch only, we defer the registration in order to reduce the overhead to uni-dispatch programs.
www.usenix.org /events/coots01/dutchyn/dutchyn_html   (8448 words)

  
 Instruction classification circuit configured to classify instructions into a plurality of instruction types prior to ...
A single dispatch instruction is dispatched to a single decode unit, while a double dispatch instruction is dispatched to a pair of decode units.
Bussing between decode units included when double dispatch instructions are detected within the decode unit may be eliminated.
Pipeline stalls created when instructions which were previously dispatched are redispatched due to the detection of double dispatch instructions at the decode stage may be eliminated.
www.delphion.com /details?pn10=US05872947   (733 words)

  
 Multiple Dispatch
Double dispatch, commonly used in C++ to implement multi-methods, does not lend easily extensible code.
Double dispatch fails to meet requirements 1 and 2.
Double dispatch is at the heart of the Visitor pattern, and several authors have tried to overcome the cyclic nature of Visitor.
www.eptacom.net /pubblicazioni/pub_eng/mdisp.html   (2726 words)

  
 code::gallery :: Single, Double And Multiple Dispatch :: July :: 2006
The dispatch in the nomenclature is about dispatching messages to objects, as it is said in Smalltalk.
In the single dispatch mechanism, the method to be invoked in determined using the object, usually type of the object, on which it is invoked.
One of the common designs of multiple dispatch is to separate the methods from the class (which contains the structure).
codegallery.blogsome.com /2006/07/22/single-double-and-multiple-dispatch   (451 words)

  
 Design Patterns - SlateWiki   (Site not responding. Last check: 2007-10-18)
Dispatches can be added to any method in any position with the "@"-notation.
Multiple dispatch helps with this, but also a module system that is multi-dispatch oriented is the key here, not defaulting to a method being "owned" by an object it's defined on.
Define a new type as a sibling of the existing type to be decorated (derive it from the first type's parent), and remove its state.
slate.tunes.org /wiki/Design_Patterns   (276 words)

  
 COMP 212 Lab 07: Double-Dispatch Pattern   (Site not responding. Last check: 2007-10-18)
In most OO languages, including Java, when you call a method on an object that belongs to a union, the call is dispatched to the appropriate method based solely on the type of the receiver.
In constrast, Mmltiple-dispatching is the ability to dispatch the appropriate method call based on the type of more than one of the parameters.
All this dispatching is computationally expensive, whereas the same goals can be obtained on primitive types more easily.
www.owlnet.rice.edu /~comp212/01-spring/labs/07   (1117 words)

  
 compile
Multiple dispatch is found in Common Lisp and other languages and is therefore not a new design pattern.
The reasons for wanting multiple dispatch or something similar in the context of adding methods to a class without modifying the class are well noted by many authors including Matthias Zenger and Martin Odersky and are also explained below in the form of a Numeric Example.
This latter reference may seem strange in the context of the Multiple Dispatch pattern because it is not concerned with multiple dispatch but is concerned with adding methods to a class without having to modify the class.
www.javalobby.org /java/forums/c6683.html   (2474 words)

  
 Visitor pattern - Wikipedia, the free encyclopedia
Thus the visitor pattern simulates double dispatch in a conventional single-dispatch object-oriented language such as Java, Smalltalk, and C++.
For an explanation of how double dispatch differs from function overloading, see Double dispatch is more than function overloading in the double dispatch article.
The use of multiple dispatch is introduced in a second example; yet the framework remains the same.
en.wikipedia.org /wiki/Visitor_pattern   (703 words)

  
 Double Dispatching in Java
The number of dispatching operations could be equal to the number of implementation classes (times the number of "actual" operations), but it is likely to be somewhat smaller than that if there is no externally important difference for the particular type's perspective.
It does cause a focal point (bottleneck) in that Addable interface: you have to have the union of all dispatching operations within it, so it will be hard to "close" it against future changes.
Of course the double dispatching itself is only a portion of the actual functionality (adding Points to Points and Points to Numbers), although it is much more significant than normal in this particularly simple and focused example.
www.chimu.com /publications/short/javaDoubleDispatching.html   (1592 words)

  
 Developing for Developers : The Visitor pattern and multiple dispatch
Now, this isn't valid C# of course, since C# doesn't support double dispatch, but you can see the effect it would have if it did: the Visitor interface is gone, the Accept() method is gone, and the calls in the last Visit() method are simplified.
If you've studied how polymorphic methods are dispatched, you're probably most familiar with the "vptr" and "vtable" model, where each object includes a reference to a type descriptor, which in turn contains a table of function pointers giving the right function to invoke for each method for an object of that type.
One of the simplest strategies, and an effective one in practice, is to have the initial vtable dispatch the method to a "stub" method, whose job is to perform another vtable dispatch on the second argument.
blogs.msdn.com /devdev/archive/2005/08/29/457798.aspx   (1939 words)

  
 JOT: Journal of Object Technology - Reflection-based implementation of Java extensions: the double-dispatch use-case, ...
Thus, at invocation time, the visitAppropriate() method simply uses its argument class and the dynamic code map to dispatch the invocation to the appropriate code.This technique avoids the use of the generic invoke() method, known to be time consuming.
At invocation time, when this concrete generated method is called, it performs a lookup in the hashtable to retrieve the method index associated with the type of its argument; if the type is not found, the method’s index for the closest type must be determined and their association is cached into the hashtable.
Then, the dispatch is performed using this index in a simple switch/case statement to call the right method.
www.jot.fm /issues/issue_2005_12/article3   (6805 words)

  
 Dr. Dobb's | Message Handling Without Dependencies | April 5, 2006
The key to Double Dispatch is that the virtual function in the message class takes the handler as a parameter, then calls another function on the handler, passing itself as a parameter.
The consequence of this is that the dependency problems of Double Dispatch promptly evaporate: Message types no longer need to be aware of each other, and handler classes only need to be aware of the messages they handle.
With this simplification, the dispatch functions in the message classes are almost identical, but not quite—they must explicitly specify the message class to which they belong, in order to cast to the appropriate handler base class.
www.ddj.com /dept/cpp/184429055?cid=RSSfeed_DDJ_Cpp   (2058 words)

  
 Double Dispatch
Actually, he concentrates on double dispatch, and only waves his hands at dispatching on n > 2 objects.
Also he uses typeid(T).name() as his type identifier key, which is not actually guaranteed to be unique, and he requires all user functions to down cast their arguments, and does not consider different base types for the same argument slots, etc. etc.
DoubleDispatch is a pattern for solving this problem in a typical OO language that can dispatch only on one object's type.
www.c2.com /cgi/wiki?DoubleDispatch   (1342 words)

  
 Extensible and efficient double dispatch in single-dispatch object-oriented programming languages - US Patent 6721807   (Site not responding. Last check: 2007-10-18)
An improved method and system is described for implementing double dispatch extensibly and efficiently in single-dispatch object-oriented programming languages.
Double dispatch takes place by calling Accept on an object of type Element, passing an object of type Visitor as an argument.
Clients that rely on double dispatch are thus unaffected by such extension.
www.patentstorm.us /patents/6721807.html   (373 words)

  
 Pattern: Double Dispatch   (Site not responding. Last check: 2007-10-18)
In Smalltalk a better solution is to make use of the polymorphic nature of the language and to use a technique known as double dispatching.
This involves adding a new method (we'll call this a secondary method) to the classes of all the potential parameter objects and then calling this from the original method with the receiver as a parameter.
The selector of the secondary method should be constructed from the primary method selector followed by the class name of the original receiver.
www.mimuw.edu.pl /~sl/teaching/00_01/Delfin_EC/Patterns/DoubleDispatch.htm   (371 words)

  
 [No title]   (Site not responding. Last check: 2007-10-18)
We can simulate double polymorphic dispatch in C++ by using a nasty trick.
This works, but it has the unfortunate characteristic that the source code for the base class depends upon the source code for the derived classes.
Clearly, if there will be many more derivatives of Shape in the future, then this method is unmanagable simply due to the geometric explosion of cominations.
cpptips.hyperformix.com /cpptips/mult_disp2.txt   (402 words)

  
 Replacing if-else chain with polymorphism   (Site not responding. Last check: 2007-10-18)
It is known as Double Dispatch, and it is used in the Visitor pattern.
With Double Dispatch, you have to create more methods - one (abstract one) in the base class, and concrete ones in each of the subclasses.
I like Double Dispatch, because once in place, it allows you to pass notifications to hosts withing having to know they type of host or the type of notification.
forum.java.sun.com /thread.jspa?threadID=418883&messageID=1854985   (1084 words)

  
 Guardian Unlimited | World dispatch | Jordan's double game over Iraq
The double doors swung open, and there - in the glare of camera lights - stood Prince Hassan of Jordan.
Jordan is almost certainly playing a double game here, or perhaps even several double games at the same time.
The late King Hussein could not have survived for so long without being adept at double games, and his son seems to have learned a few tricks from him too.
www.guardian.co.uk /elsewhere/journalist/story/0,7792,755704,00.html   (1331 words)

  
 Double Dispatch alternitive - GameDev.Net Discussion Forums
But using the Double Dispatch Pattern would result in very bloated classes with the need for a specific method to handle each type of class.
Additionally, this would move the drag and drop code to the Scene Graph layer (from the GUI layer, which would be bad since the drag and drop function should be a semantic of the GUI).
An alternative to consider when the number of combinations is large is dispatch using a map.
www.gamedev.net /community/forums/topic.asp?topic_id=173053   (802 words)

  
 Bibliography Site   (Site not responding. Last check: 2007-10-18)
Goals of flexibility and re-usability in typed object-oriented languages suggest the requirement of double dispatch, i.e., the mechanism of dynamically selecting a method not only according to the run-time type of the receiver (single dispatch), but also to the run-time type of the argument.
In this paper we present a general technique for adding double dispatch as a type-safe language feature, so yielding dynamic overloading and covariant specialization of methods, without extending basic semantics.
Then we define a translation algorithm from multi methods to the core language, that implements double dispatch by using only standard mechanisms of static overloading and single dispatch.
rap.dsi.unifi.it /~bettini/bibliography/paper_details.php?paperid=76   (316 words)

  
 Double Dispatch Example
Double dispatch is used when two abstractions intersect.
One level of dispatch is always "easy", in that it can be extended without changing existing code.
The second is always "harder", in that the new elements have to added to the existing first-level dispatch code.
c2.com /cgi/wiki?DoubleDispatchExample   (3171 words)

Try your search on: Qwika (all wikis)

Factbites
  About us   |   Why use us?   |   Reviews   |   Press   |   Contact us  
Copyright © 2005-2007 www.factbites.com Usage implies agreement with terms.