pouet.chapril.org est l'un des nombreux serveurs Mastodon indépendants que vous pouvez utiliser pour participer au fédiverse.
Chapril https://www.chapril.org est un projet de l'April https://www.april.org

Administré par :

Statistiques du serveur :

1,1K
comptes actifs

@inthehands @luna they are thread safe.
The interleave pb is a different issue
I am not aware of languages that keep natively internal buffer per thread to avoid interleaving.

Do you have any example ?

@johan @luna
I would not describe having a nondeterministic race condition between format specifiers from different threads as being “thread safe,” except in the most uselessly pedantic way imaginable.

And no, I can’t think of another language that has this problem, because all of them use that magic native internal buffer we refer to as “local expression evaluation.”

@inthehands @luna ok I see where we disagree.
Stream operators are not equivalent to print statement, each data being fed asap by design.

And I agree this might be considered as a strange choice to promote this as a default way of printing.

@johan @inthehands @luna yeah, precisely. The "print statement" in C++ is the same as in C: printf and cousins.

operator<< is ... an operator and is not inherently more (or less) thread-safe than operator+ or operator=.

I also agree that is may be considered strange to promote an operator as the default way of printing.

@PaulDavisTheFirst @johan @luna
`cout <<` is the generally accepted idiom for printing to stdout in C++, no doubt about that — and yes, promoting that way is strange!

Technicalities about implementation (“`<<` is just another operator,” “it’s thread-safe at the level of individual stream insertions”, etc) are missing the point. The •standard idiom• is a footgun. That’s the point.