Polymorphism (computer science): Difference between revisions

Content deleted Content added
No edit summary
Ad hoc polymorphism: Improved a sentence to be understood easier.
Line 19:
===Ad hoc polymorphism===
{{main|Ad hoc polymorphism}}
[[Christopher Strachey]] chose the term ''ad hoc polymorphism'' to refer to polymorphic functions that can be applied to arguments of different types, but that behave differently depending on the type of the argument to which they are applied (also known as [[function overloading]] or [[operator overloading]]).<ref name=Strachey00/> The term "[[ad hoc]]" in this context is not intended to be pejorative; it refers simply to the fact that this type of polymorphism is not a fundamental feature of the type system. In the [[Pascal (programming language)|Pascal]] / [[Delphi (programming language)|Delphi]] example below, the <code>Add</code> functions seem to work generically over varioustwo types (integer and string) when looking at the invocations, but are considered to be two entirely distinct functions by the compiler for all intents and purposes:
 
<syntaxhighlight lang="Pascal">