also known as "bindings" (especially when talking about an environment)
issue: nested definitions
class C
{
int a, b;
...
public void f()
{
int x = a + b;
String a = "a and b is "; // new declaration of a - hides older one
System.out.println(a + x);
}
}
track which binding of a is being accessed by which statement
implementation
simple method (imperative): map from variables to a stack of bindings
push new binding when define new variable
pop appropriate stacks when leave scopes
requires tracking what variables are defined in each scope
alternative method (functional): use a tree with a different root for each
scope
This is a useful optimization, but not necessary for this term's project