In dynamically typed languages the situation can be more complex as the correct function that needs to be invoked might only be determinable at run time. Writeln(Add('Hello, ', 'Mammals!')) (* Prints "Hello, Mammals!" *) end. In the Pascal / Delphi example below, the Add functions seem to work generically over various types when looking at the invocations, but are considered to be two entirely distinct functions by the compiler for all intents and purposes: ![]() 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. Types Ad hoc polymorphism Ĭhristopher 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). In a 1985 paper, Peter Wegner and Luca Cardelli introduced the term inclusion polymorphism to model subtypes and inheritance, citing Simula as the first programming language to implement it. Ad hoc polymorphism was a feature of Algol 68, while parametric polymorphism was the core feature of ML's type system. ![]() Ad hoc polymorphism and parametric polymorphism were originally described in Christopher Strachey's Fundamental Concepts in Programming Languages, where they are listed as "the two main classes" of polymorphism. Interest in polymorphic type systems developed significantly in the 1960s, with practical implementations beginning to appear by the end of the decade.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |