Content deleted Content added
Magioladitis (talk | contribs) m →References: WP:CHECKWIKI errors fixed using AWB (9087) |
Crosbiesmith (talk | contribs) →Early binding: rm. 5-year-old unexplained 'factual accuracy' tag |
||
Line 2:
== Early binding==
Ad hoc polymorphism is a [[Dynamic dispatch|dispatch]] mechanism: control moving through one named function is dispatched to various other functions without having to specify the exact function being called. Overloading allows multiple functions taking different types to be defined with the same name; the [[compiler]] or [[Interpreter (computing)|interpreter]] automatically calls the right one. This way, functions appending lists of integers, lists of strings, lists of real numbers, and so on could be written, and all be called ''append''—and the right ''append'' function would be called based on the type of lists being appended. This differs from parametric polymorphism, in which the function would need to be written ''generically'', to work with any kind of list. Using overloading, it is possible to have a function perform two completely different things based on the type of input passed to it; this is not possible with parametric polymorphism. Another way to look at overloading is that a routine is uniquely identified not by its name, but by the combination of its name and the number, order and types of its parameters.
|