Fork me on GitHub
#core-async
<
2017-08-31
>
ajmagnifico19:08:05

Question: is (binding) going to behave like I think it should when I’m using go blocks?

hiredman19:08:34

it depends how you think binding should behave, and what parts of it you are using

hiredman19:08:48

clojurescript, absolutely not

ajmagnifico19:08:00

yeah, I’m not in clojurescript

hiredman19:08:09

I forget if clojurescript even has a binding macro, but if it does it shouldn't

ajmagnifico19:08:17

but I was using binding to re-route println to a different writer

ajmagnifico19:08:27

but things ended up going to stdout anyway

ajmagnifico19:08:41

so I was just checking to see if “everybody knows that you shouldn’t use binding in go blocks!”

hiredman19:08:47

it will matter when and how oyu establish the binding

ajmagnifico19:08:50

because every now and then, I make those kinds of mistakes

tbaldridge19:08:21

go blocks carry the bindings from outside the block

hiredman19:08:29

like, if you bind out around the creating of the go block, then for the duration of that go block, unless the go block changes it, code in the go block will see the value you bound for out

ajmagnifico19:08:31

okay, but if I bind inside of the go block …

tbaldridge19:08:39

it works fine as well, just tried it

hiredman19:08:04

inside the go block you have to assume you are already running on another thread

ajmagnifico19:08:27

it’s also possible that I’m in the fog of post-lunch needing a nap 😄

hiredman19:08:41

so the binding machinery works fine, but if you are initing the binding from another thread local, etc, things can end up not working as expected

tbaldridge19:08:09

It should work exactly like bindings with future

hiredman19:08:51

like, if you have a threadlocal, or something that behaves like one, that the binding conveyance knows nothing about