Fork me on GitHub
#clojure
<
2021-09-09
>
roklenarcic18:09:30

In my clojure.core.async/alt! one of the input channels gets closed. After it is closed alt! will always read from that channel, and ignore other channels, just returing infinite nil . Is there a way around it?

hiredman18:09:28

a closed channel is always "readable" and the result is nil

hiredman18:09:39

if you know a channel is closed (because you read nil from it) then you need to stop trying to read from it

roklenarcic18:09:05

Right, but if the channel doesn’t have anything to read from it, I would like to process data from another channel.

hiredman19:09:23

A closed channel has a infinite sequence of nils to read from it, not nothing, like calling first on an empty list

p-himik19:09:17

You should be able to use alts! instead - it allows for dynamic channel lists.

roklenarcic19:09:09

Thanks I’ll look at it.