title: Dynamic Scoping - Deep Binding vs Shallow Binding
body: <p>I've been trying to get my head around shallow binding and deep binding, wikipedia doesn't do a good job of explaining it properly. Say I have the following code, what would the output be if the language uses dynamic scoping with</p>
  
  <p>a) deep binding</p>
  
  <p>b) shallow binding?</p>
  
  <pre><code>x: integer := 1
  y: integer := 2
  
  procedure add
    x := x + y
  
  procedure second(P:procedure)
    x:integer := 2
    P()
  
  procedure first
    y:integer := 3
    second(add)
  
  ----main starts here---
  first()
  write_integer(x)
  </code></pre>