core-async

rgm 2019-08-01T04:42:05.080900Z

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.

rgm 2019-08-01T04:42:57.082300Z

I’m using vim/nrepl/fireplace so I’m wondering if the output is just getting swallowed in that chain someplace.

2019-08-01T05:08:57.084300Z

In general prn in a go block works like prn in a future

2019-08-01T05:10:13.086500Z

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

rgm 2019-08-01T10:55:16.087900Z

Cool, thanks. That might give me a shorter repro for sorting out what’s going on.

alexmiller 2019-08-01T12:00:36.090400Z

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

alexmiller 2019-08-01T12:01:29.091400Z

If not, then printing would go to stdout instead of whatever you rebound to

2019-08-01T15:23:39.093200Z

Go blocks do binding conveyance, they capture the binding frames in the array and restore them

2019-08-01T15:25:52.095700Z

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

ghadi 2019-08-01T15:32:31.096200Z

(what go blocks don't support is changing binding in the middle of execution)

rgm 2019-08-01T15:34:50.097500Z

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

rgm 2019-08-01T15:36:23.097900Z

using clean deps with only clojure and core async.

rgm 2019-08-01T15:39:29.099200Z

(this is that vim business earlier, except I think I’ve messed up somewhere and it can’t be the vim/fireplace pipeline).

ghadi 2019-08-01T16:01:36.099900Z

@rgm looks fine -- it's probably the printing with nREPL

ghadi 2019-08-01T16:02:10.100600Z

try sending a value to a "logging" channel that you can view

ghadi 2019-08-01T16:02:31.101400Z

or if you're using REBL, you can tap> and the tapped values will show up in REBL

ghadi 2019-08-01T16:02:52.102300Z

(nREPL might not capture prints that happen in a background thread)

rgm 2019-08-01T16:03:10.102800Z

oh, you’re right … I think it is nrepl… I forgot that my ~/.deps had that included by default.

rgm 2019-08-01T16:03:18.103100Z

:face_palm:

ghadi 2019-08-01T16:03:36.103500Z

btw, in general printing or other I/O in a go block is a no-no

ghadi 2019-08-01T16:03:46.103800Z

not explicitly forbidden, but can lead to deadlocks

rgm 2019-08-01T16:05:09.105Z

understood.

rgm 2019-08-01T16:13:35.106900Z

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