> I think if Clojure could do something like this (enforce a certain
> kind of referentially transparent mutable local), that would be neat,
It is possible to achieve this behavior explicitly:
(defn create-add-2 []
(with-local-vars [x 1]
(do
(var-set x 2)
(let [z @x]
(fn [y] (+ y z))))))
(def myc (create-add-2))
user=> (myc 1)
3
user=> (myc 2)
4
A bit verbose, but also very clear about what is really mutable and
what isn't.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---