Ask HN: What algorithm is commonly used in Static Scope implementation

1 points by ejanus ↗ HN
I am currently trying to understand programming language design, and I am also reading source codes of a couple of languages. I would need help in understanding how Static Scope is implemented. Are there some popular algorithms out there I might need to go through? Any links? And if there is someone out there currently designing and implementing a language who won't mind having a mentee (online)?

1 comment

[ 2.6 ms ] story [ 12.3 ms ] thread
Scoping is literally just a sequential list of associative lists to check in order. Nothing more than that.

Its simple to implement as a stack of hash tables, pushing a new hash table onto the stack when entering a scope, popping one off when you leave the scope. declarations add entries into the hash table at the top of the stack. Lookups traverse the stack top to bottom.