title: How is Lexical Scoping implemented?
body: <p>A couple of years ago I started writing an interpreter for a little Domain Specific Language which included programmer-defined functions. </p>
  
  <p>At first I implemented variable scope using a simple stack of symbol-tables. But now I want to move to proper lexical scoping (with the option of closures). Can anyone explain the data-structure and algorithm behind lexical scope? </p>