template statistics
Stanislav Blinov
stanislav.blinov at gmail.com
Thu Jun 4 04:40:07 UTC 2020
On Thursday, 4 June 2020 at 01:38:50 UTC, Walter Bright wrote:
> On 6/3/2020 3:21 PM, Steven Schveighoffer wrote:
>> Unless you are suggesting that Phobos completely drop support
>> for interleaving printf and writeln calls? If you are, I
>> assure you Walter will not accept that.
>
> I just checked with him, and he assured me he won't.
:)
> Also, a plain writeln("hello") must be thread safe just like
> puts("hello"). The reason is simply customer demand. I recall
> the bad old days when multiple threads would write to stdout,
> and you'd get:
>
> heworllldo
That's simple, multiple threads shouldn't be writing to stdout ;)
And that's only a half-joke. There of course must be a
thread-safe writeln, just as there must be a non-thread-safe
writeln (with different names, obviously). Which is the default
should depend on the program. If you're only running one thread,
or more to the point, only doing stdout from one thread [at a
time], you have no use for those kinds of locks. It's just waste
of cache. If you're not using any C libraries, or ones you are
using aren't doing stdout, you have no use for FILE*. The OS is
right there, a syscall away.
Phobos does make provisions for rolling your own sink
(formattedWrite), which is great (more templates though :P). But,
when you do sit down to write your own, core.sys is startlingly
deprived of sys and is full of C. And now it becomes a roll your
own syscalls... And then you find core.osthread full of pthread
and not osthread.
More information about the Digitalmars-d
mailing list