There are several few old blog posts that caution when mixing dynamic variables bindingand pmapfor example. here where we get the following code snippet:
user=> (def *foo* 5)
user=> (defn adder
[param]
(+ *foo* param))
user=> (binding [*foo* 10]
(doseq [v (pmap adder (repeat 3 5))]
(println v)))
10
10
10
nil
But this is not what happens when I run this code (changing the first line to (def ^:dynamic *foo* 5)). I get three 15as output (using Clojure 1.4), just as you naively expect & mdash, i.e. with a change in the binding form visible by the function passed to pmap. How has the interaction of flows and local pmap connections changed? I canโt find it anywhere anywhere.
ben w source
share