Made my day that it references an article I wrote! :-D<p>Another thing that is kinda neat: there is a duality (a bidirectional transform) between the AST for a tree walking interpreter and the AST for a stack machine. To create the stack machine AST, all you do is remove any occurrence of the expression type in the tree-walking AST; these values are now found on the stack. Obvious when you think about it, but useful nonetheless. I don't think there is a simple equivalent for a register machine as, unless you have an infinite number of registers, you need to do register allocation.<p>(If the author reads this, my name changed from Noel to Neal at some point. I don't really mind though; my name is a bit unusual and I've been called all sorts of things.)
> (If the author reads this, my name changed from Noel to Neal at some point. I don't really mind though; my name is a bit unusual and I've been called all sorts of things.)<p>I think it'd be good to update the about page with that info: <a href="https://noelwelsh.com/landing/about/" rel="nofollow">https://noelwelsh.com/landing/about/</a>
Just read your blog post[0], thanks for it!<p>If I may leave some feedback here...<p>It'd be cool if you could add some syntax highlighting, because being at it is, it's hard to distinguish comments from code paths. The code snippets are just Scala anyway, aren't they?<p>Why, in the <i>switch dispatch</i>- and the <i>subroutine threading</i>-variants, is the recursive call in the <i>dispatch</i> function done with a call to <i>loop(...)</i>? Is that some Scala specific thing for recursion?<p>[0]: <a href="https://noelwelsh.com/posts/understanding-vm-dispatch/" rel="nofollow">https://noelwelsh.com/posts/understanding-vm-dispatch/</a>
Hmm, what's a stack machine AST? I can't follow your description of the transform, what does "remove" mean here? I can remove all of the internal nodes of a tree, which leaves me with a soup of leaf nodes, but how is that an AST for a stack machine?