Re:Making a programming language using Rust
by siraben on Monday November 09, 2020 @04:38AM
(#25033042)
> then you get tail-calls for every function, which effectively obviates the stack.
This is true, however CPS moves the work from the stack to the heap, so a deep enough recursion would exhaust the heap instead. Using a trampoline[0] in conjunction with CPS ensure constant stack usage for tail-recursive functions.
This is true, however CPS moves the work from the stack to the heap, so a deep enough recursion would exhaust the heap instead. Using a trampoline[0] in conjunction with CPS ensure constant stack usage for tail-recursive functions.
[0] https://en.wikipedia.org/wiki/Trampoline_(computing)