Racket has the nice read-bytes-async!
function, which I believe exists in every other programming language in the world. It reads what it can from an input stream, without blocking, into a buffer, returning the number of bytes written.
Said function seems like an absolutely essential function for efficiently implementing, say, the Unix cat
tool, yet Chicken Scheme seems to lack any such function. Of course, I can use (read-byte)
and (write-byte)
, but that is slow and eats up all my CPU.
Even (copy-port)
seems to not have any such implementation. Instead, before the stream is closed, the data is copied buffer-by-buffer only when the buffers fill. This means that (copy-port (current-input-port) (current-output-port))
does not behave like cat
at all.
Am I just suffering from a terrible blind spot in reading the documentation, or does Chicken shockingly actually lack such a function? So cat
can't even be written efficiently in Chicken?