Reputation: 295262
I'm trying to use set!
to modify the thread-local bindings of a var -- but these changes don't appear to be taking effect. Consider the following:
(def ^:dynamic *foo* :root)
(binding [*foo* :thread-local]
(let [val (doto :new
#(set! *foo* %))]
[val *foo*]))
I would expect the result to be [:new :new]
; instead, this evaluates to [:new :thread-local]
. What am I misunderstanding here?
Upvotes: 2
Views: 159
Reputation: 17299
Your doto
syntax is wrong.
(binding [*foo* :thread-local]
(let [val (doto :new (#(set! *foo* %)))]
[val *foo*]))
Note the additional parens.
Upvotes: 2