Why are globals set to tls by default? and why is fast code ugly by default?

Nick Treleaven nick at geany.org
Sun Mar 26 18:29:17 UTC 2023


On Sunday, 26 March 2023 at 18:07:03 UTC, ryuukk_ wrote:
> What i find even more weird is writing fast code is ugly in D
>
> Look at this ugly code
>
> ```D
> __gshared int fast_code_ugly;
> ```

Because it should be rare that __gshared is used. And if you need 
it, you won't be worried about how the storage class looks 
because you'll be concentrating on if your design is thread-safe.

> It should be the opposite

Then by default, @safe code can not access global variables and 
there can easily be accidental races between threads.


More information about the Digitalmars-d-learn mailing list