Multimethods

Multiple dispatch.
Developers of computer software typically organize source code into named blocks called variously subroutines, procedures, subprograms, functions, or methods. (The choice of term depends on the language being used and, sometimes, on subtle differences between their characteristics.) The name of a function is used to refer to it from other source code; this is referred to as calling the function. When code is executed, a reference to a function causes control to be transferred temporarily to that block of code, and later return to the instructions following the function call. Function names are usually selected so as to be descriptive of the function's purpose. Sometimes, it is desirable to give several functions the same name, often because they perform a conceptually similar task, but operate on different types of input data. In such cases, the name reference at the function call site is not sufficient for identifying the block of code to be executed. Instead, the number and type of the arguments to the function call are also used to select among several function implementations. When working with languages that can discriminate data types at compile-time, selecting among the alternatives can occur at compile-time. The act of creating such alternative functions for compile-time selection is usually referred to as overloading a function. In programming languages that defer data type identification until run-time, the selection among alternative functions can occur at run-time, based on the dynamically-determined types of function arguments. Functions whose alternative implementations are selected in this manner are referred to most generally as multimethods. Most object-oriented languages allow a limited form of multimethod selection based on a single, special argument to the function. This is called virtual method selection, or single dispatch. Where the selection of a multimethod depends on 2 or more arguments we call this double dispatch or multidispatch. There is some run-time cost associated with dynamically dispatching function calls. In some languages, the distinction between overloading and multimethods can be blurred, with the compiler determining whether compile-time selection can be applied to a given function call, or whether slower run-time dispatch is needed. Programming languages that support general multimethods: * Python (via the module gnosis.magic.multimethods)

 

<< PreviousWord BrowserNext >>
art spiegelman
new zealand prostitutes' collective
cambridge, new zealand
1999 governor general's awards
prostitution in new zealand
robert merle
hmy britannia
invader zim
jhonen vasquez
constantine v
1998 governor general's awards
eddie santiago
comair
northern mindanao
sandy cheeks
patrick star
metrobius
squidward tentacles
mobile suit victory gundam
gundam x
1997 governor general's awards
mobile fighter g gundam
tony award for best revival of a musical
turn a gundam
mobile suit gundam seed
tony award for best revival of a play
betty friedan
padiddle
list of mayors of minneapolis
governor of hawaii
governor of illinois
governor of kansas
governor of north carolina
zurich international airport
sakura wars
narita international airport
arpanet
fancy lala
san francisco municipal railway
bikini bottom
operation olympic
iso 3166 2:ae
mpeg 4 part 3
haruhiko mikimoto