-
-
Notifications
You must be signed in to change notification settings - Fork 392
Description
Splitting this discussion off from #796, and specifically the subthread starting here
On another note: as I write
receive_exactlyandreceive_untiland 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/writethat refer to modifying passive media – and also it's good to avoid associations with Python's conventions aroundread, which are really inappropriate forStreams and forChannels, for different reasons. Butreceiveis just an awkward word: kinda long, annoying to spell. I'd be tempted byget/put, except then we'd haveStream.get_someand 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/receiveon the other hand is for bytestreams and similar where the focus of these methods is on partitioning the stream into semantic chunks.Calling
receive_exactlyon four bytes (and then N bytes) to de-partition a byte-encoded message > stream makes sense.
Callingget_exactlyto read N HTTP requests or MQTT messages? not so much.Yes,
receiveis awkward. So … userecvinstead?
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.sendandChannel.receive, and for byte streams we haveStream.send_allandStream.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_exactlywould take aStreamspecifically, not aChannel, so I don't think there'd be any confusion about using it for MQTT.