Content deleted Content added
clarifying lead |
|||
Line 1:
In [[programming languages]], '''ad-hoc polymorphism'''<ref>C. Strachey, Fundamental concepts in programming languages. Lecture notes for International Summer School in Computer Programming, Copenhagen, August 1967</ref>
== Early binding==
{{Disputed-section|date=March 2008}}
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.
|