Description
Splitting this discussion off from #796, and specifically the subthread starting here
On another note: as I write
receive_exactly
andreceive_until
and receive receive receive, I'm somewhat regretting the decision to name our primitivessend
/receive
. I do like the emphasis that these are active transfers "in the moment", versusread
/write
that refer to modifying passive media – and also it's good to avoid associations with Python's conventions aroundread
, which are really inappropriate forStream
s and forChannel
s, for different reasons. Butreceive
is just an awkward word: kinda long, annoying to spell. I'd be tempted byget
/put
, except then we'd haveStream.get_some
and that seems like a bad idea.give
/take
?put
/take
?put_all
/get_any
? Or just stick withsend
/receive
... Maybe this should be a separate issue.
WRT put/get: Umm … thinking about it, put/get works for single messages, while send/receive makes more sense for byte/character streams. This is because I associate put/get with things like channels or queues that you can use to put some single thing in on one end and get it out the other end.
send
/receive
on the other hand is for bytestreams and similar where the focus of these methods is on partitioning the stream into semantic chunks.Calling
receive_exactly
on four bytes (and then N bytes) to de-partition a byte-encoded message > stream makes sense.
Callingget_exactly
to read N HTTP requests or MQTT messages? not so much.Yes,
receive
is awkward. So … userecv
instead?
thinking about it, put/get works for single messages, while send/receive makes more sense for byte/character streams. This is because I associate put/get with things like channels or queues that you can use to put some single thing in on one end and get it out the other end.
That's why I find them attractive :-). For single objects we currently have
Channel.send
andChannel.receive
, and for byte streams we haveStream.send_all
andStream.receive_some
. So in all cases, the verb on its own is being used to refer to single objects, and then sometimes we have a modifier to make it plural.And
get_exactly
would take aStream
specifically, not aChannel
, so I don't think there'd be any confusion about using it for MQTT.