Newb question: I’m trying to prn
a value from within a go block in the JVM, just to make sure things are wired up right. Is it ordinary behaviour for no output to happen? I can confirm that the <!
in the go block is working by conjing the value onto a vector in an atom and dereffing.
I’m using vim/nrepl/fireplace so I’m wondering if the output is just getting swallowed in that chain someplace.
In general prn in a go block works like prn in a future
So if prns in a future get swallowed in your tool chain of choice (ouch, that is rough) then that will often happen with go blocks
Cool, thanks. That might give me a shorter repro for sorting out what’s going on.
Is that actually right @hiredman ? prn will print to *out*
. Futures do binding conveyance but do go blocks? I don’t know off the top of my head
If not, then printing would go to stdout instead of whatever you rebound to
Go blocks do binding conveyance, they capture the binding frames in the array and restore them
The thing I don't recall is if go blocks will run on the current thread up until the first channel operation, which would behave differently from futures
(what go blocks don't support is changing binding in the middle of execution)
https://clojure.atlassian.net/projects/ASYNC/issues/ASYNC-170
I think I have a fundamental misunderstanding here and would appreciate some help … even from clj
this code doesn’t print anything https://gist.github.com/rgm/dff54483f0705918191f48d461b33687
using clean deps with only clojure and core async.
(this is that vim business earlier, except I think I’ve messed up somewhere and it can’t be the vim/fireplace pipeline).
@rgm looks fine -- it's probably the printing with nREPL
try sending a value to a "logging" channel that you can view
or if you're using REBL, you can tap>
and the tapped values will show up in REBL
(nREPL might not capture prints that happen in a background thread)
oh, you’re right … I think it is nrepl… I forgot that my ~/.deps had that included by default.
:face_palm:
btw, in general printing or other I/O in a go block is a no-no
not explicitly forbidden, but can lead to deadlocks
understood.
@ghadi @hiredman @alexmiller thanks for helping … yep, the prn is getting swallowed by nrepl. Guess I’ll try that same code with prepl out of curiosity (notwithstanding the general idea of don’t-do-IO-in-go-blocks).