[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Question about an error with ports
From: |
Olivier Dion |
Subject: |
Re: Question about an error with ports |
Date: |
Thu, 10 Mar 2022 10:05:12 -0500 |
On Thu, 10 Mar 2022, Zelphir Kaltstahl <zelphirkaltstahl@posteo.de> 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
- Question about an error with ports, Zelphir Kaltstahl, 2022/03/09
- Re: Question about an error with ports,
Olivier Dion <=
- Re: Question about an error with ports, Zelphir Kaltstahl, 2022/03/10
- Re: Question about an error with ports, Olivier Dion, 2022/03/10
- Re: Question about an error with ports, Chris Vine, 2022/03/11
- Re: Question about an error with ports, Olivier Dion, 2022/03/11
- Re: Question about an error with ports, Chris Vine, 2022/03/11
- Re: Question about an error with ports, Olivier Dion, 2022/03/11
- Re: Question about an error with ports, Chris Vine, 2022/03/11
- Re: Question about an error with ports, Maxime Devos, 2022/03/11
- Re: Question about an error with ports, Maxime Devos, 2022/03/11
- Re: Question about an error with ports, Chris Vine, 2022/03/11