¶Continuation-passing S₀: The return
Lately I've been noodling on a four-stack variant of S₀. Unrelated to its four-stackness, it is also no longer a CPS language — when you invoke a quotation, control returns back to the next instruction once the quotation's body is complete.
I now think I want to go back to CPS. One of the reasons for abandoning it was that it made it harder to juggle the inputs, continuation, and receiver of each invocation. But we can handle that with multiple stacks.
So my current thinking is three stacks: a working stack, a continuation stack, and a locals stack. All quotations would close over a stack of values. Invoking a quotation would _replace_ the locals stack with those values before executing the chosen branch. (That means that the locals stack must be empty at the start of an invocation, so that we don't leak values.) The continuation stack exists mostly to solve the juggling problem. The receiver and inputs of an invocation will be on the working stack.
This is no longer the stack layout that I'm actually using; I've switched to “Bethel stacks”.