On Sunday, February 26, 2017 at 6:23:28 AM UTC+1, Didier wrote: > > Dynamic scoping and Java ThreadLocals gives you equal functionality, so > I'd use them equally. This is because Clojure supports thread bound dynamic > scope. >
I wouldn't say that. While dynamically scoped Vars are meant to be context that you implicitly pass down to your call stack, ThreadLocals are references that you can pass around explicitly at will. Java ThreadLocals also provide an .initialValue() callback to override, which is not provided by Vars. Vars can't even be (idiomatically) initialized to a thread-bound value. I think that the fact that dynamically scoped Vars are implemented by ThreadLocals is an implementation detail, and it is not a feature, it is more of a limitation. (I guess implementing it otherwise is difficult, if viable at all). Thanks -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.