Dynamic Scoping

Dynamic scoping — the name is looked up at runtime.


Image


Values are placed in stacks, with one value stack per name.  Only the top-most value is visible.


Static Scoping

Static scoping — the compiler looks up the names and assigns absolute locations for them at compile time.  After compilation, the names are discarded.


In most languages, there are two places that variables can reside:

  1. global memory
  2. stack.


Image


The compiler assigns an absolute index for each name.  Names are stripped away after compilation.