Resolving and Binding
As someone with years of experience writing interpreters, this seems a rather sloppy solution to a straightforward problem. There are two canonical solutions, and he uses neither:<p>1. The first canonical solution, which the author even describes, is persistent environments. Unfortunately, this requires passing the current environment as part of the recursive pattern, which means heavily modifying the existing code. He doesn&#x27;t do this because it would require revisiting too much.<p>2. The second canonical solution, which you would find in any modern compiler, is to uniquely rename all the variables. His &quot;resolver&quot; traversal has ample opportunity to do this, and would provide a far cleaner solution (with less space overhead than his expr&#x2F;scope depth lookup table).<p>Instead, the author creates a stack of environments and annotates variables with information akin to de Bruijn indicies <i>for scopes</i>. Compared to the alternatives above, this is over-engineered and inelegent, plus it complicates reasoning about scopes far beyond what&#x27;s necessary.<p>As an aside, this assertion is also completely absurd:<p>&gt; Shadowing is rare and often an error so initializing a shadowing variable based on the value of the shadowed one seems unilkely [sic] to be deliberate.