template statistics
Adam D. Ruppe
destructionator at gmail.com
Thu Jun 4 03:14:58 UTC 2020
On Thursday, 4 June 2020 at 03:00:26 UTC, Steven Schveighoffer
wrote:
> buffer, otherwise, e.g. you will be issuing system calls for
> writing 5 bytes, followed by an immediate system call for 5
> more.
Yeah, I know. You and I have both written low-level I/O code, we
both know how it works and the huge difference proper buffering
can make.
But the question is where do you have implicit flushes? I'm
arguing for at the end of the function.
The call to writefln or whatever would do an intermediate buffer,
but when it returns, it flushes it all at once. You don't flush
intermediates if you can get away with it, but you treat each
function as a direct write.
If a user actually writes out `write("h"); write("e");
write("l");`, well, that's on them, maybe they wanted to see it
spell out!
But if they write `writefln("hello, %s, you have %d points!",
name, score);`, the implementation should NOT do
os.write("hello, ");
os.write(name);
os.write(", you have ");
no, it should go ahead and buffer those pieces, then at the very
end write it all.
Just again, if the USER writes it out in separate calls... well,
that's on them.
This will match what happens in most cases anyway since the C
buffer DOES flush on \n most the time (and when it doesn't, users
complain and I have to explain it to them AGAIN)
getting a lil off topic for templates btw.......
More information about the Digitalmars-d
mailing list