On Thu, 10 Mar 2022, Zelphir Kaltstahl <[email protected]> wrote:
> I have the following questions:
>
> (1) Is the read-from-write-to procedure useful at all, or is there a better
> way
> to get all stuff from an input port and output it to an output port, avoiding
> possibly large string values?
On Linux, there's slice(2) for pipes that does exactly that.
Otherwise, I think this version is a better fit
(define splice
(lambda (in-port out-port)
"Read from an IN-PORT and write to OUT-PORT"
(let loop ([bv (get-bytevector-some in-port)])
(unless (eof-object? bv)
(put-bytevector out-port bv)
(loop (get-bytevector-some in-port))))))
you should not close OUT-PORT. This break the REPL in my case if using
the `current-output-port`.
--
Olivier Dion
Polymtl