Handling package and class scopes in Unicon
Creating symbol tables for Jzero considers two scopes: class and local. Since Jzero does not do instances, Jzero’s class scope is static and lexical. A larger, real-world language must do more work to handle scopes. Java, for example, must distinguish when a symbol declared in the class scope is a reference to a variable shared across all instances of the class, and when the symbol is a normal member variable that’s been allocated separately for each instance of the class. In the case of Jzero, an isMember
Boolean can be added to the symbol table entries to distinguish member variables from class variables, similar to the isConst
flag.
Unicon’s implementation is a lot different than Jzero’s. A summary of its symbol tables and class scopes allows for a fruitful comparison. Whatever it does similarly to Jzero might also be how other languages handle things. What Unicon does differently than Jzero, each language...