Show HN: Clojure by Example
This is a great project!<p>I believe there's a lack of clarity in the let form explanation:<p><pre><code>  =>(let [object "light"]
  =>  (let [object "darkness"])
  =>  (println (str "God said let there be " object)))
  God said let there be light
  nil
</code></pre>
'object' is overwritten but only within the second let form:<p><pre><code>  =>(let [object "light"]
  =>  (let [object "darkness"]
  =>    (println (str "God said let there be " object))))
  God said let there be darkness
  nil
</code></pre>
or even:<p><pre><code>  =>(let [object "light"]
  =>  (println (str "God said let there be " object))
  =>  (let [object "darkness"]
  =>    (println (str "God said let there be " object))))
  God said let there be light
  God said let there be darkness
  nil
</code></pre>
The reason for this is the let form uses lexical scoping.  In other words it creates a new frame which includes the bindings declared in the square brackets.  When 'object' is evaluated its binding is looked for in the current frame, then the frame that called that frame and all the way out into the global namespace stopping when a binding is found.<p>See also: <a href="http://stackoverflow.com/questions/1774417/scoping-rules-in-clojure" rel="nofollow">http://stackoverflow.com/questions/1774417/scoping-rules-in-...</a>