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?
Your
dotosyntax is wrong.Note the additional parens.