Any chance that this could be supported now core.async is here? I think the arguments of brandon bloom are still valid. I have implemented Erlang-like supervisors for core.async and now got stuck in the last step when I realized that the supervisor binding is broken in cljs. (1) I can pass explicit arguments everywhere as a work-around, but this is not necessary on the JVM and makes the error-handling a lot less seamless. A binding fits nice for supervision. core.async would need to be extended as well, but I would be willing to put the effort in, if the approach is acceptable.
Cheers, Christian (1) https://github.com/whilo/full.monty/blob/master/full.async/src/full/lab.cljc#L74 Am Montag, 14. Januar 2013 13:29:10 UTC+1 schrieb David Nolen: > > There is not. > > On Monday, January 14, 2013, Stuart Campbell wrote: > >> Sorry to dig up such an old thread. >> >> I'd also like to maintain the bindings of dynamic vars across >> asynchronous function calls. >> >> Is there a workaround that people use in the absence of bound-fn, etc? >> >> Cheers, >> Stuart >> >> On Friday, 27 January 2012 16:49:10 UTC+11, Brandon Bloom wrote: >>> >>> The ClojureScript wiki >>> <https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure> >>> states that "the user experience of [binding] is similar to that in >>> Clojure" but my very first experiment produced wildly different results >>> between platforms. >>> >>> Here's a Clojure on the JVM session: >>> >>> user=> (import java.lang.Thread) >>> java.lang.Thread >>> user=> (defn set-timeout [ms fn] (.run (Thread. #(do (Thread/sleep ms) >>> (fn))))) >>> #'user/set-timeout >>> user=> (def x "top level") >>> #'user/x >>> user=> (binding [x "in binding"] (println x) (set-timeout 1000 #(println >>> x))) >>> in binding >>> in binding >>> nil >>> >>> And here's the analogous ClojureScript session: >>> >>> ClojureScript:cljs.user> (def x "top level") >>> "top level" >>> ClojureScript:cljs.user> (binding [x "in binding"] (println x) >>> (js/setTimeout #(println x) 1000)) >>> in binding >>> 21 >>> top level >>> >>> So ignoring the sequencing and nil vs timeout-id return values, the >>> binding of 'x wasn't preserved in the asynchronous callback. >>> >>> I raised this issue in #clojure and @dnolen said that "that's the >>> behavior there's nothing much to fix", but that didn't sit right with me. >>> This seems like either 'binding is bugged, or maybe I don't understand >>> something about its intent. >>> >>> On the topic of "Vars" proper, I understand their usefulness in >>> repl-centric development, where you can redefine functions at runtime. The >>> wiki also makes some mention of this, but I can't wrap my head around the >>> context and jargon. I've run into this problem before in Javascript, where >>> some level of indirection is necessary to support run-time redefinitions. >>> You can't do `var fn = package.fn;` and dynamically redefine `fn` from >>> `package` later because a copy of the reference is made. How does >>> ClojureScript address this problem? >>> >>> Cheers, >>> Brandon >>> >> -- >> 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 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.