Should we breathe new life into readavailable
?
#57994
Labels
io
Involving the I/O subsystem: libuv, read, write, etc.
readavailable
?
#57994
The function
readavailable
is in an awkward position. The documentation says:This makes it sound like it does the following:
This reply implies that that's indeed what it does.
It's also what the default definition of
write(::IO, ::IO)
implies it doesHowever, in the docstring, the sentence is followed by the warning:
And the comments in #16821 also implies that this function should not be used at all.
But why? Isn't it quite useful to have a function that reads all the available data? To be sure, I'm a bit bummed out that
readavailable
doesn't actually read the available bytes, which you would really, really think it did from its name, but apparently also does a blocking operation if that number is zero.I think it would be nice to either:
readavailable
will return all of the bytes given bybytesavailable
if that is nonzero, or else do one blocking read, and will read what becomes available from that, and remove the warning from the docstring, orreadavailable
to do what it says on the tin and read exactly the available bytes, no less, no more.The latter would be nicer, but is slightly breaking and may be too breaking.
And maybe there's a reason for the warning?
The text was updated successfully, but these errors were encountered: