Proper tail recursion and space efficiency

@article{Clinger1998ProperTR,
  title={Proper tail recursion and space efficiency},
  author={William D. Clinger},
  journal={Proceedings of the ACM SIGPLAN 1998 conference on Programming language design and implementation},
  year={1998}
}
  • W. Clinger
  • Published 1 May 1998
  • Computer Science
  • Proceedings of the ACM SIGPLAN 1998 conference on Programming language design and implementation
The IEEE/ANSI standard for Scheme requires implementations to be properly tail recursive. This ensures that portable code can rely upon the space efficiency of continuation-passing style and other idioms. On its face, proper tail recursion concerns the efficiency of procedure calls that occur within a tail context. When examined closely, proper tail recursion also depends upon the fact that garbage collection can be asymptotically more space-efficient than Algol-like stack allocation.Proper… 

Figures from this paper

Managing continuations for proper tail recursion
TLDR
This paper discovered that an abstract machine that runs CPS-converted programs cannot be considered properly tailrecursive if continuation closures are simply created with the lexical environments for all variables, and proposes new techniques to implement a properly tail-recursive Scheme interpreter in an extended C language by following space-efficiency based definitions of proper tail recursion.
A Tail-Recursive Semantics for Stack Inspections
TLDR
An abstract machine for a language with security stack inspection whose space consumption function is equivalent to that of the canonical tail call optimizing abstract machine is exhibited and suggests that tail-calls are as easy to implement in a security setting as they are in a conventional one.
A tail-recursive machine with stack inspection
TLDR
An abstract machine for a language with security stack inspection whose space consumption function is equivalent to that of the canonical tail call optimizing abstract machine is exhibited and suggests that tail calls are as easy to implement in a security setting as they are in a conventional one.
Efficient and safe-for-space closure conversion
TLDR
This paper presents a new algorithm that exploits the use of compile-time control and data-flow information to optimize funtion calls and adopts the strong safe-for-space-complexity rule, thus achieving good asymptotic space usage.
The Tail-Recursive SECD Machine
TLDR
This document argues that the use of tail-recursive abstract machines incurs only a small increase in theorem-proving burden when compared with what is required when using ordinary abstract machines.
Performance Benefits of Tail Recursion Removal in Procedural Languages
TLDR
It is suggested that, due to its low cost and high benefit, the removal of tail recursion is a useful optimization in a compiler for a procedural language.
QUANTIFYING TAIL RECURSION, RECURSION AND ITERATION
TLDR
It is concluded that the recursive version is fastest than the tail recursive and iterative version and evidence to show the utility of recursion over tail recursion and iteration is presented.
Revised6 Report on the Algorithmic Language Scheme
TLDR
Scheme demonstrates that a very small number of rules for forming expressions, with no restrictions on how they are composed, suffice to form a practical and efficient programming language that is flexible enough to support most of the major programming paradigms in use today.
Bounding space usage of conservative garbage collectors
TLDR
It is shown that if the program manipulates only data structures satisfying a simple GC-robustness criterion, then a bounded number of misidentified pointers can at most result in increasing space usage by a constant factor.
Modular verification of assembly code with stack-based control abstractions
TLDR
This paper presents a simple but flexible Hoare-style framework for modular verification of assembly code with all kinds of stackbased control abstractions, including function call/return, tail call, setjmp/longjmp, weak continuation, stack cutting, stack unwinding, multi-return function call, coroutines, and thread context switch.
...
...

References

SHOWING 1-10 OF 56 REFERENCES
Efficient stack allocation for tail-recursive languages
  • C. Hanson
  • Computer Science
    LISP and Functional Programming
  • 1990
The Scheme dialect of Lisp [9] is properly tail-recuraiwit relies entirely on procedure calls to express iteration. In Scheme, a tail-recursive procedure call (that is, a call in which the calling
CONS should not CONS its arguments, part II: Cheney on the M.T.A.
TLDR
This Scheme proposes solving the tail-recursion problem in the same manner as Standard ML of New Jersey, by allocating all frames in the (garbage-collected) heap.
Empirical and Analytic Study of Stack Versus Heap Cost for Languages with Closures
TLDR
A comprehensive analysis of all the components of creation, access and disposal of heap-allocation and stack-allocated activation records shows that heap frames are simpler to implement and allow very efficient first-class continuations.
Storage use analysis and its applications
TLDR
A new program analysis method which is called Storage Use Analysis, which deduces how objects are used by the program and allows the optimization of their allocation, and shows the application of this analysis to two important optimizations: stack allocation and unboxing.
An Empirical and Analytic Study of Stack vs . Heap Cost for Languages with Closures
TLDR
A comprehensive analysis of all the components of creation, access, and disposal of heap-allocation and stack-allocated activation records is presented, showing that the cache write-miss rate of heap frames is very high; it is shown that a variety of miss-handling strategies can give good performance, but not all can.
Abstract models of memory management
TLDR
A series of calculi are developed that are just low-level enough that they can express allocation and garbage collection, yet are sufficiently abstract that they may formally prove the correctness of various memory management strategies.
Lambda, the ultimate label or a simple optimizing compiler for Scheme
TLDR
Lambda lifting makes optimizing compilers for higher-order languages practical by eliminating all non-local variables except for those that would have to be allocated in the heap anyway.
Rabbit: A Compiler for Scheme
TLDR
A compiler for the lexically-scoped dialect of LISP known as SCHEME, which handles only a small basis set which reflects the semantics of lambda-calculus, and serves to produce code as good as that produced by more traditional compilers.
Implementation of the typed call-by-value λ-calculus using a stack of regions
TLDR
The translation is proved correct with respect to a store semantics, which models as a region-based run-time system for polymorphically typed call-by-value λ-calculus.
...
...