Dynamic Dispatch

The selection of a method to run based on both a) its signature, and b) the type of one or more of its arguments. Feature found in all OO languages. In many languages, all method calls are potentially dynamic (though Static Dispatch may be used as an optimization). In others, such as Cee Plus Plus, functions have to be explicitly declared to use dynamic dispatch (the virtual keyword does this in C++; a virtual function is little more than one that uses dynamic dispatch).

There are several types of Dynamic Dispatch:

Single Dispatch. Found in most OO languages (Smalltalk Language, Java Language, Cee Plus Plus); only one argument (usually given a special name like "this" or "self") is used (along with the method signature) to select the method to run. Easy to implement, and meshes well with the encapsulation semantics of many OO languages.

Multiple Dispatch (Multi Methods). Found in Dylan Language, available in Common Lisp Object System. More than one (potentially all) arguments to a method are used to select the method to run. Doesn't mesh as well with object ownership semantics, and harder to implement efficiently. A special case of Multiple Dispatch is Double Dispatch, which is useful when implementing binary operators.

See original on c2.com