dcreager.net

Four stacks

  • Stack 0: Inputs and outputs of invocations
  • Stack 1: Invocation receivers, enclosed values
  • Stack 2: Local scratch space
  • Stack 3: Local scratch space

Putting invocation receivers and enclosed values on the same stack makes sense, because then invoking a quotation will “replace” the quotation with its enclosed value before the selected branch starts executing. (Note that you can invoke a quotation from any stack, it's just that doing so from stack 1 will be most typical. Invoking from stack 0, for instance, is possible, but then you have to do more complicated dig/bury dances to line up the parameters just right.)

Updates

This is no longer the stack layout that I'm actually using; I've switched to “Bethel stacks”.

Bethel stacks