Let bindings map pretty much directly to Java style local variables: (let [x 42] (let [x 3] (+ x 3))
Becomes something like this when compiled to byte code: x_1 = 42 x_2 = 3 return x_2 +3 So let bindings with the same names are kept separate via modifying the stored name in the byte code, and these local variables are never overwritten except via a loop. Let bindings in Clojure are not "reified" (not something you can reference), they are simply names for calculated values. Contrast this with a var. Vars however are reified. You can look at a var in Clojure: (def foo 42) #'foo => <Var ...> (deref #'foo) => 42 The #' reader macro says "get me the var with this name, but don't call deref on it; I want the actual var". That's not something you can do with let bindings since they are not a first class object in the language. Timothy On Sat, Dec 3, 2016 at 10:06 PM, Paul Gowder <paul.gow...@gmail.com> wrote: > That's a really neat post. Thank you for writing it! > > How do bindings created by let fit into that picture? > > The question of how vars work comes up enough that I recently wrote a blog > post on the subject. Maybe it will be useful to you. > http://blog.cognitect.com/blog/2016/9/15/works-on-my- > machine-understanding-var-bindings-and-roots > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- “One of the main causes of the fall of the Roman Empire was that–lacking zero–they had no way to indicate successful termination of their C programs.” (Robert Firth) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.