Deeply impressive work! It’s amazing that you’ve managed to get so much working so quickly.
I’m a little surprised to see this, though in retrospect it makes sense. I wonder how other interpreted languages deal with this problem? After all, most languages use scopes in one way or another. It may be worth looking at how R implements it, since variable lookup there also requires searching through environment lists.
Though I do spy one low-hanging fruit…
Might it not be quicker to use a hashmap or similar data structure?