What do you think about the naming of the `close` ...
# coroutines
m
What do you think about the naming of the
close
method on
SendChannel
? IMO it’s a bit confusing, because it brings up the idea of a
Closeable
, which is very different (especially since there are plenty of channels which don’t need to be closed because they send indefinitely). The documentation leads me to suggest something like
sendLast
, which I think would convey the intent better.
s
Or maybe even ‘complete()’, to use a Rx-like verb.
👍 2
e
But it is a channel. Just like a network socket. So you close it. That is the verb you ought to use for it.
4
s
Closing a channel closes it for sending, but not (necessarily) receiving.
m
Would you say that using a channel without closing it is a mistake? I don’t see anything in the documentation to suggest that, and I think that there’s plenty of valid use-cases for it. I think that’s where the confusion with `Closeable`’s
close
comes from. The channel doesn’t hold any resources AFAIK, so it’s more specific than the socket.
e
It does hold resources. There is another coroutine in the other side, waiting. And if you don’t close the channel it is stuck. It is completely different concept than Rx.
m
I see your point. In practice, I often find that the waiting coroutine has a scope which means that takes care of its own cancellation, therefore I don’t need to close the channel. Maybe I’m using channels too much like streams of events.
s
@elizarov Good points. Yeah, then using the name ‘complete’ is not the best choice 🙂