On 12/09/12 16:29, the80srobot wrote:
What I usually do when I want to avoid passing these implicit parameters is just use thread-local bindings with ^:dynamic vars. From the point to rebind them using (bindings), every function called from within the binding block sees the same value; you can combine them with atoms/agents/refs for even greater flexibility, and still avoid polluting your namespace. One way to think about that, in my opinion, is that by having your namespace top-level vars hold references to state, you are effectively turning your namespace into a singleton object, which is typically not a good idea even in Java. Starting with Clojure 1.3.0, I believe pmap and some other core functions that work with threads even take care of propagating your thread-local bindings to child threads for you.

dealing with lots of dynamic vars can be tricky and makes the code less readable...can also introduce bugs...the purpose of dynamic vars is not to model state...we've got reference types for that...

yes, binding conveyance makes sure your dynamic bindings are propagated appropriately...still don't like them!

Jim

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to