Skip to main content
Use bullets. Expand strong.
Source Link
Shaun Luttin
  • 142.8k
  • 93
  • 443
  • 495

Polymorphism allows the same routine (function, method) to act on different types.

Since many existing answers are conflating subtyping with polymorphism, here are three ways (including subtyping) to implement polymorphism. Parameteric (generic) polymorphism allows a routine to accept one or more type parameters, in addition to normal parameters, and runs itself on those types. Subtype polymorphism allows a routine to act on any subtype of its parameters. Ad hoc polymorphism generally uses routine overloading to grant polymorphic behavior, but can refer to other polymorphism implementations too.

  • Parameteric (generic) polymorphism allows a routine to accept one or more type parameters, in addition to normal parameters, and runs itself on those types.
  • Subtype polymorphism allows a routine to act on any subtype of its parameters.
  • Ad hoc polymorphism generally uses routine overloading to grant polymorphic behavior, but can refer to other polymorphism implementations too.

See also:

http://wiki.c2.com/?CategoryPolymorphism

https://en.wikipedia.org/wiki/Polymorphism_(computer_science)

Polymorphism allows the same routine (function, method) to act on different types.

Since many existing answers are conflating subtyping with polymorphism, here are three ways (including subtyping) to implement polymorphism. Parameteric (generic) polymorphism allows a routine to accept one or more type parameters, in addition to normal parameters, and runs itself on those types. Subtype polymorphism allows a routine to act on any subtype of its parameters. Ad hoc polymorphism generally uses routine overloading to grant polymorphic behavior, but can refer to other polymorphism implementations too.

See also:

http://wiki.c2.com/?CategoryPolymorphism

https://en.wikipedia.org/wiki/Polymorphism_(computer_science)

Polymorphism allows the same routine (function, method) to act on different types.

Since many existing answers are conflating subtyping with polymorphism, here are three ways (including subtyping) to implement polymorphism.

  • Parameteric (generic) polymorphism allows a routine to accept one or more type parameters, in addition to normal parameters, and runs itself on those types.
  • Subtype polymorphism allows a routine to act on any subtype of its parameters.
  • Ad hoc polymorphism generally uses routine overloading to grant polymorphic behavior, but can refer to other polymorphism implementations too.

See also:

http://wiki.c2.com/?CategoryPolymorphism

https://en.wikipedia.org/wiki/Polymorphism_(computer_science)

added 65 characters in body
Source Link
Shaun Luttin
  • 142.8k
  • 93
  • 443
  • 495

Polymorphism allows the same routine (function, method) to act on different types.

Since many existing answers are conflating subtyping with polymorphism, here are three ways (including subtyping) to implement polymorphism. Parameteric (generic) polymorphism allows a routine to accept one or more type parameters, in addition to normal parameters, and runs itself on those types. Subtype polymorphism allows a routine to act on any subtype of its parameters. Ad hoc polymorphism generally uses routine overloading to grant polymorphic behavior, but can refer to other polymorphism implementations too.

See also:

http://wiki.c2.com/?CategoryPolymorphism

https://en.wikipedia.org/wiki/Polymorphism_(computer_science)

Polymorphism allows the same routine (function, method) to act on different types.

Since many existing answers are conflating subtyping with polymorphism, here are three ways (including subtyping) to implement polymorphism. Parameteric (generic) polymorphism allows a routine to accept one or more type parameters, in addition to normal parameters, and runs itself on those types. Subtype polymorphism allows a routine to act on any subtype of its parameters. Ad hoc polymorphism generally uses routine overloading to grant polymorphic behavior, but can refer to other polymorphism implementations too.

See also:

http://wiki.c2.com/?CategoryPolymorphism

Polymorphism allows the same routine (function, method) to act on different types.

Since many existing answers are conflating subtyping with polymorphism, here are three ways (including subtyping) to implement polymorphism. Parameteric (generic) polymorphism allows a routine to accept one or more type parameters, in addition to normal parameters, and runs itself on those types. Subtype polymorphism allows a routine to act on any subtype of its parameters. Ad hoc polymorphism generally uses routine overloading to grant polymorphic behavior, but can refer to other polymorphism implementations too.

See also:

http://wiki.c2.com/?CategoryPolymorphism

https://en.wikipedia.org/wiki/Polymorphism_(computer_science)

added 293 characters in body
Source Link
Shaun Luttin
  • 142.8k
  • 93
  • 443
  • 495

Polymorphism Polymorphism allows the same routine (function, method...) to operateact on different types (at different times).

HereSince many existing answers are someconflating subtyping with polymorphism, here are three ways (including subtyping) to implement polymorphism. Parameteric (generic) polymorphism allows a routine to accept one or more type parameters, in addition to normal parameters, and runs itself on those types. Subtype polymorphism allows a routine to act on any subtype of its parameters. Ad hoc polymorphism generally uses routine overloading to grant polymorphic behavior, but can refer to other polymorphism implementations too.

  • Static Polymorphism
  • Parameteric Polymorphism
  • Subtype Polymorphism
  • Ad Hoc Polymorphism

See also:

Many answers are conflating sub-typing and abstraction with polymorphism.http://wiki.c2.com/?CategoryPolymorphism

Polymorphism allows the same routine (function, method...) to operate on different types (at different times).

Here are some ways to implement polymorphism.

  • Static Polymorphism
  • Parameteric Polymorphism
  • Subtype Polymorphism
  • Ad Hoc Polymorphism

Many answers are conflating sub-typing and abstraction with polymorphism.

Polymorphism allows the same routine (function, method) to act on different types.

Since many existing answers are conflating subtyping with polymorphism, here are three ways (including subtyping) to implement polymorphism. Parameteric (generic) polymorphism allows a routine to accept one or more type parameters, in addition to normal parameters, and runs itself on those types. Subtype polymorphism allows a routine to act on any subtype of its parameters. Ad hoc polymorphism generally uses routine overloading to grant polymorphic behavior, but can refer to other polymorphism implementations too.

See also:

http://wiki.c2.com/?CategoryPolymorphism

Source Link
Shaun Luttin
  • 142.8k
  • 93
  • 443
  • 495
Loading