I was surprised to discover that the following was possible:
(let [
x 1
y 2
x (+ x y) ]
x )
This runs and returns 3!
This feels an awful lot like variables and procedural programming.
It is left up to the developer to not resetting a "variable" - by
convention - and if he reset the identifiers, he ends up with hard-to-
debug spagetti-code.
I would have thought that the system would have protested when I
attempted to set 'x' to a new value!
Amit Rathore writes in "Clojure In Action" about : "[...] are locally
named values (they are like variables, but they can’t vary since
Clojure’s data-structures are immutable)"
In combination underscore identifiers for throw-away return values,
one can in fact write a whole procedural program within the vector
parens of a let-statement!
Perhaps this is something that should be changed in future versions of
the language?!
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en