On 12/02/2015 01:53, Ben Wolfson wrote:
The multiple-binding form of let can be recursively transformed into
nested lets:

(let [name1 value1 name2 value2 ... name value] body)
---->
(let [name1 value1] (let [name2 value2] ...  (let [name value] body)))

All you're doing with your let form is shadowing the name; there's no
mutation. If you had something like this:

(let [x 1]
    (let [x (inc x)]
      (println x))  ;; prints 2
    (println x)) ;; prints 1

it would be more obvious; it's less apparent in your case because
there's no room for the extra forms.


That explains it but I think Clojure's syntax is misleading here. Without knowledge of this magic the mind doesn't readily translate:

(let [x 1
        x (inc x)
        x (inc x)
        x (inc x)]
   x)


.... into:

(let [x 1]
  (let [x (inc x)]
    (let [x (inc x)]
      (let [x (inc x)]
  x))))

The single bracket pair in the original leads the unwitting newcomer to assume all the x'es are in the same scope.

gvim






--
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.

Reply via email to