[plt-scheme] interleaving the I and O in I/O
Chongkai Zhu wrote:
>> So, a followup I should have asked at the time: is there any way for
>> the user to modify this behaviour? Specifically, I want to avoid
>> having the current output port flushed every time there is a read. --PR
>
> If you are not output to the interaction session, than just use (output
> ... your-port) instead of using the current output port. Even if you do
> want to output to the interaction session, the following code will can
> do the trick:
>
> (define output-port (current-output-port))
> (current-output-port (make-output-port #f always-evt void void))
MzScheme seems to dislike that use of void for the "write-proc" argument
of make-output-port.
But perhaps I was not clear in my expectation. I would like students to
be able to write code which reads from standard input and writes to
standard output, knowing that they will test their code using file
redirection and that we will test it in the same fashion. I would like
them to not have to pay the penalty of having the current output port
flushed every time there is a read, so that they can interleave reads
and printfs (= writes) in their program and not make it slower. Is there
a simple way of achieving this goal? --PR