3 ms·
> In F, everything is a function from triples of (environment;stack;queue) to triples of (environment;stack;queue). I dabble with compiler-writing, and one of
by mrkeen 2y ago
> In F, everything is a function from triples of (environment;stack;queue) to triples of (environment;stack;queue).
I dabble with compiler-writing, and one of the techniques there is to program an abstract machine. It fills a nice niche - it's a bit more concrete than hacking together an interpreter over your AST, and a lot less concrete than writing out LLVM instructions.
Some examples are Krivine machines and SECD machines (which stands for Stack, Environment, Control, Dump).
They let you play around with ideas before you commit to a particular semantics of your language, for instance, whether you'll pass by value or reference, via the stack, or via the heap.
But exposing (e;s;q) directly to the programmer is a fascinating idea! If I'm thinking about it right, it means a programmer could write code to take a parameter which was passed in via the stack, and decide "No I think this should be on the heap instead" and then update all pointers in the program accordingly.