This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-05-13
Channels
- # beginners (17)
- # boot (16)
- # cider (13)
- # cljs-dev (26)
- # cljsrn (5)
- # clojure (155)
- # clojure-belgium (2)
- # clojure-spec (19)
- # clojure-uk (4)
- # clojurescript (32)
- # community-development (16)
- # core-async (12)
- # cursive (3)
- # datomic (7)
- # hoplon (14)
- # lambdaisland (1)
- # lumo (16)
- # microservices (1)
- # off-topic (3)
- # om (5)
- # onyx (4)
- # protorepl (1)
- # re-frame (1)
- # rum (1)
- # specter (6)
- # unrepl (32)
@cgrand how far are you from a cljs unrepl? And how can I contribute to it? I saw once one namespace to port to cljs...
@richiardiandrea it's print.clj the key namespace to port.
Kk I will have a look there...anything I need to be aware of?
Got it, yeah dynamic vars in cljs - no good 😀
The bindings last only the time to print the value. No callback, no laziness. Should be safe.
Well in any case it is single threaded
Uhm I don't understand the connection to binding
of the above statement
Dynamic vars are not casting process boundaries anyways right?
I think christophe means this:
cljs.user=> (def ^:dynamic x :foo)
#'cljs.user/x
cljs.user=> (binding [x :bar] (prn x))
:bar
nil
cljs.user=> (binding [x :bar] (js/setTimeout #(prn x)))
#object[Timeout [object Object]]
cljs.user=> :foo
Oh ok yes that's​ right , thank you sorry for misunderstanding 😀
I don’t think Clojure suffers from the same issue
even if it does you can get around it with bound-fn
http://blog.cognitect.com/blog/2016/9/15/works-on-my-machine-understanding-var-bindings-and-roots works with futures. But this isn't quite what I expect:
user=> (binding [*x* :bound] (.start (Thread. (fn [] (Thread/sleep 10) (prn *x*)))))
nil
:initial
user=> (.start (Thread. (binding [*x* :bound] (fn [] (Thread/sleep 10) (prn *x*)))))
nil
:initial
sure, because bindings are thread local
@anmonteiro I don't understand really, futures are a separate thread. I thought bindings were "forking" by some description.
boot.user=> (binding [*x* :bound] (.start (Thread. (fn [] (Thread/sleep 10) (prn *x*)))))
nil
:initial
boot.user=> (binding [*x* :bound] (.start (Thread. (bound-fn [] (Thread/sleep 10) (prn *x*)))))
nil
:bound
yeah, future
clones the bindings in place
Got it, and no bound-fn in clojurescript it seems. https://github.com/binaryage/cljs-zones somebody is on it.
yeah, there has been some discussion in #cljs-dev about it before
IIRC the last discussion was started by Cristophe who was looking for an old bound-fn proposal
@anmonteiro I'm still working on a new proposal but bound-fn is the wrong solution for cljs
Yeah that bound-fn
issue for cljs is very old...Prolly using cljs-zones is the quickest for now
Didn't know that future was special thanks for sharing !
newborn-zone
is epic ahah. Interesting that every async trick in js ends up being code transformation and functions basically
@anmonteiro I'm still working on a new proposal but bound-fn is the wrong solution for cljs