Jump to content

Polymorphic recursion

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Nic Waller (talk | contribs) at 17:25, 25 October 2009 (started article). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

Polymorphic recursion exists in a data structure when the data structure is recursive, and it uses generics for the recursion, and it is recursing on itself with a different generic type.

In some strongly typed languages, such as C++, polymorphic recursion is difficult to implement because all data types are determined during compilation. Polymorphic recursion causes data types to be infinitely nested, forcing the compiler to throw an error.

Examples

(Bootstrapping Stack goes here)