|
|
|
|
|
by kazinator
465 days ago
|
|
> I'm interested in examining the idea of a programming language that eschews the notion of a callstack Chicken Scheme fits the bill. While it doesn't eschew the notation of a call stack, it turns it on its ear. In Chicken Scheme 1. All objects are allocated on the stack. Strings, conses, symbols, lexical environments, ... 2. Functions do not return. Everything is compiled to C which uses continuation passing style. What looks like returning in the Scheme source code is a continuation call: the parent function passes a continuation, and so the function return invokes that and runs that lambda. 3. Because functions do not return and everything is allocated from the stack, the stack grows voraciously. When it hits a certain limit, a kind of ephemeral garbage collection takes place: all objects that have been allocated on the stack which are still live are transferred to the heap. Then ... the stack pointer is rewound. Essentially, the C stack has become a bump allocator in a kind of generational GC. |
|