What Is "Open Recursion"?
9 days ago
- #programming
- #object-oriented
- #lambda-calculus
- Open recursion is a term introduced by Pierce in 'Types and Programming Languages' to describe extensions needed to build object-oriented languages from simpler languages with functions and records.
- Recursion in this context refers to the mutual recursion of method definitions, allowing methods to see and call each other regardless of their declaration order.
- Open refers to the ability of base methods to access overridden methods in derived objects, achieved by passing the receiver object explicitly.
- The example demonstrates creating a counter object with methods that can call each other (recursion) and modifying it to log calls by overriding methods (open).
- Key differences from simpler languages include mutual recursion of methods and access to derived objects, enabling features like method overriding.