Tuesday, March 12, 2013

Polymorphism


3 Types:
  1. Ad-hoc polymorphism
  2. Parametric polymorphism
  3. Subtype polymorphism (or inclusion polymorphism)
Subtype polymorphism (or inclusion polymorphism): In object-oriented programming, subtype polymorphism or inclusion polymorphism is a concept in type theory wherein a name may denote instances of many different classes as long as they are related by some common super class.[1] Inclusion polymorphism is generally supported through subtyping, i.e., objects of different types are entirely substitutable for objects of another type (their base type(s)) and thus can be handled via a common interface.

Parametric polymorphism: Parametric polymorphism allows a function or a data type to be written generically, so that it can handle values identically without depending on their type.[4] Parametric polymorphism is a way to make a language more expressive, while still maintaining full static type-safety.
Parametric polymorphism is ubiquitous in functional programming, where it is often simply referred to as "polymorphism". The following example shows a parametrized list data type and two parametrically polymorphic functions on them:

Look further into Type Theory.

In mathematics, logic, and computer science, type theory generally refers to a class of formal systems, some of which can serve as alternatives to naive set theory as a foundation for all mathematics. In type theory, every "term" has a "type" and operations are restricted to terms of a certain type.

http://en.wikipedia.org/wiki/Type_theory

No comments:

Post a Comment