unrepl

discussing specification of an edn-based repl and its implementations.
richiardiandrea 2017-05-13T15:19:50.986321Z

@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...

cgrand 2017-05-13T15:48:18.095999Z

@richiardiandrea it's print.clj the key namespace to port.

richiardiandrea 2017-05-13T15:51:22.107578Z

Kk I will have a look there...anything I need to be aware of?

cgrand 2017-05-13T15:52:59.114026Z

It depends on a couple of dynamic vars which are defined in unrepl.core

cgrand 2017-05-13T15:53:45.116991Z

So you will have to stub or port them.

richiardiandrea 2017-05-13T16:19:11.222044Z

Got it, yeah dynamic vars in cljs - no good πŸ˜€

cgrand 2017-05-13T16:23:10.238389Z

The bindings last only the time to print the value. No callback, no laziness. Should be safe.

richiardiandrea 2017-05-13T16:48:12.334974Z

Well in any case it is single threaded

cgrand 2017-05-13T17:16:33.447688Z

One thread does not equate one logical process.

richiardiandrea 2017-05-13T17:33:08.511026Z

Uhm I don't understand the connection to binding of the above statement

richiardiandrea 2017-05-13T17:34:37.516147Z

Dynamic vars are not casting process boundaries anyways right?

pesterhazy 2017-05-13T17:39:34.534400Z

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

richiardiandrea 2017-05-13T17:41:24.541186Z

Oh ok yes that's​ right , thank you sorry for misunderstanding πŸ˜€

dominicm 2017-05-13T18:26:21.710252Z

binding works more like with-redefs in cljs vs clj then? 😞

dominicm 2017-05-13T18:28:36.718542Z

Oh, same problem in clj. Need to go look into this :thinking_face:

anmonteiro 2017-05-13T18:33:57.739172Z

I don’t think Clojure suffers from the same issue

anmonteiro 2017-05-13T18:34:10.740073Z

even if it does you can get around it with bound-fn

dominicm 2017-05-13T18:37:07.751599Z

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

anmonteiro 2017-05-13T18:38:26.756576Z

sure, because bindings are thread local

dominicm 2017-05-13T18:39:57.761937Z

@anmonteiro I don't understand really, futures are a separate thread. I thought bindings were "forking" by some description.

anmonteiro 2017-05-13T18:40:34.764516Z

@dominicm

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

dominicm 2017-05-13T18:41:22.767956Z

ah, so future is a special case then really?

anmonteiro 2017-05-13T18:42:34.773011Z

yeah, future clones the bindings in place

dominicm 2017-05-13T18:45:41.784885Z

Got it, and no bound-fn in clojurescript it seems. https://github.com/binaryage/cljs-zones somebody is on it.

anmonteiro 2017-05-13T18:46:46.789049Z

yeah, there has been some discussion in #cljs-dev about it before

anmonteiro 2017-05-13T18:47:11.790458Z

IIRC the last discussion was started by Cristophe who was looking for an old bound-fn proposal

richiardiandrea 2017-05-13T18:48:49.796676Z

Yeah that bound-fn issue for cljs is very old...Prolly using cljs-zones is the quickest for now

richiardiandrea 2017-05-13T18:56:01.823801Z

Didn't know that future was special thanks for sharing !

richiardiandrea 2017-05-13T19:03:30.852823Z

newborn-zone is epic ahah. Interesting that every async trick in js ends up being code transformation and functions basically