dcreager.net

Towers of stacks

2023-11-02

Counterpoint to

Staged stacks are just values

Like [Amin2017], we might have a tower of stacks in Swanson. Each basic instruction includes a “delta” indicating which stack it operates on. Stack 0 is the “current” stack, the primary stack that the program operates on. Stacks 1+ are “staged” stacks using their terminology. In some sense, they're not really any different than stack 0. But typically you'd use them to interpret a program in another language. Stack 0 would hold the current runtime state of the interpreter, and stack 1 would hold the current runtime state of the interpreted program. The interpreter somehow translates the other language into a sequence of S₀ instructions, and applies those instructions to stack 1.

[Amin2017] Collapsing towers of interpreters

When invoking a quotation (which must be at the top of one of the stacks), all of the instructions in the quotation's body execute as if its stack is stack 0. (This is why instructions have deltas — from the point of view of any given instruction, stack 0 is the stack containing the quotation containing the instruction.)

..