Example code in std.logger.core doesn't even work

mw mw at g.c
Thu Jul 13 00:29:31 UTC 2023


On Wednesday, 12 July 2023 at 23:11:00 UTC, Jonathan M Davis 
wrote:

>>
>> Sigh, D is so broken on such basic stuff.
>
> In general, objects are not supposed to be constructed as 
> shared or even really operated on as shared. ...
> a shared reference precisely because doing so would not be 
> thread-safe.
> 
> ...
>
> Ultimately, you have to do basically the same stuff in 
> languages like C or C++, but in those languages, you don't have 
> the compiler trying to prevent you from doing anything that


I think the current D confused the users:

1) why such simple program has compiler errors?


https://run.dlang.io/is/2k9Uvu
```
import std.logger;

void main() {
     std.logger.sharedLog.trace("msg");
}

```

2) it is named `std.logger.sharedLog` from the standard library, 
the users would expect it's thread safe, otherwise, why don't 
just name it `std.logger.Log`, then user would not have such 
wrongful expectations.

3) if it's not provided at all, or not named that way, the users 
will write their own synchronized thread safe loggers. (Since 
standard library does not provide a ready made one out-of-box).


That is why I said: sign, D is so broken on such basic stuff.

The users have to learn it the hard way, and each users have to 
develop their own basic thread safe logging library.





More information about the Digitalmars-d mailing list