Abstract:
Previous Schemes for implementing full tail-recursion when compiling into C have required some form of "trampoline" to pop the stack. We propose solving the tail-recursion problem in the same manner as Standard ML of New Jersey, by allocating all frames in the (garbage-collected) heap. The Scheme program is translated into continuation-passing style, so the target C functions never return. The C stack pointer then becomes the allocation pointer for a Cheney-style copying garbage collection scheme. Our Scheme can use C function calls, C arguments, C variable-arity functions, and separate compilation without requiring complex block-compilation of entire programs. Introduction IEEE Scheme [IEEE90] requires that all functions be properly tail-recursive, in order that tail-recursive programs not require an unbounded amount of stack space. Several Scheme compilers have targeted the C language [Bartlett89], because C is an efficient systems programming language which is available on nearly ev...
Citations
|
479
|
The Implementation of Functional Programming Languages
– Jones
- 1987
|
|
200
|
A nonrecursive list compacting algorithm
– Cheney
- 1970
|
|
196
|
List processing in real time on a serial computer
– Baker
- 1978
|
|
186
|
Standard ML of New Jersey
– Appel, MacQueen
- 1991
|
|
158
|
Simple generational garbage collection and fast allo-cation
– APPEL
- 1989
|
|
101
|
Garbage collection can be faster than stack allocation
– Appel
- 1987
|
|
92
|
Lambda Calculus Schemata
– Fischer
- 1972
|
|
72
|
CONS should not evaluate its arguments
– Friedman, Wise
- 1976
|
|
62
|
Scheme->c: A portable Scheme-to-C compiler
– Bartlett
- 1989
|
|
60
|
A runtime system
– Appel
- 1990
|
|
26
|
Implementation strategies for continuations
– Clinger, Hartheimer, et al.
- 1988
|
|
20
|
Efficient stack allocation for tail-recursive languages
– Hanson
- 1990
|
|
15
|
CONS Should not CONS its Arguments, or, A Lazy Alloc is a Smart Alloc
– Baker
- 1992
|
|
15
|
Memory Allocation and Higher-Order Functions
– Danvy
- 1987
|
|
11
|
Standard for the Scheme Programming Language
– IEEE
- 1990
|
|
11
|
Using and Porting GNU
– Stallman
- 1990
|
|
4
|
Block Structure: Retention vs. Deletion
– Berry
- 1971
|
|
4
|
TIM: a simple abstract machine to execute supercombinators
– Fairbairn, Wray
- 1986
|
|
3
|
Phantom Stacks: If you look too hard, they aren't there
– Stallman
- 1980
|
|
3
|
The M.T.A." On the album The Kingston Trio At Large, released June 8
– Steiner, Hawkes
- 1959
|