On Mon, Jan 9, 2012 at 2:20 PM, Shantanu Kumar <kumar.shant...@gmail.com> wrote: >> #3 seems unlikely to be implemented. ClojureScript doesn't have Vars, and >> it doesn't have threads, so there's not much for `binding` to do. I could >> see `with-redefs` being supported, however. > > Hi Stuart, > > Thanks for the pointers. So, I am trying to understand what is the > canonical way to write code that works the same on both Clojure and > ClojureScript. When I use `binding` my intentions are: > 1. Rebind the dynamic vars with common parameters so that the > intermediate calls don't need to pass the args around. > 2. Make it local to the current thread if the platform supports multi- > threading. > > If ClojureScript were to fall back to internally using `with-redefs` > every time it encountered `binding` that should be OK because there is > no multi-threading on the platform. Is it possible to detect the > current environment (CLJ vs CLJS) and execute separate code based on > that?
It's a library macro and CLJ and CLJS have different versions of the library. They already behave differently: binding works in CLJ and produces a not found error in CLJS. Adding a binding macro (that just punts to with-redefs) to the CLJS library would suffice (given a CLJS with-redefs implementation, of course). -- 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