Prime sieve language race

ag0aep6g anonymous at example.com
Wed Jul 14 12:08:29 UTC 2021


On 14.07.21 09:08, Sebastiaan Koppe wrote:
> On Tuesday, 13 July 2021 at 19:45:48 UTC, ag0aep6g wrote:
>> On Tuesday, 13 July 2021 at 19:06:12 UTC, Bastiaan Veelo wrote:
>>>     // If not called from multiple threads, this can be trusted.
>>
>> I.e., it can't be trusted. When a function needs a comment that 
>> explains how to call it safely, then it's an @system function.
> 
> Why can't non-threadsafe functions be @safe? Because it might corrupt 
> memory?
> 
> On a static function that is probably the right thing to do. But what 
> about with a member function? I would argue it isn't.

You would argue that a function that might corrupt memory should be 
@trusted when it's a member function?

If the function might corrupt memory, it must be @system. This is how I 
understand the comment.
If the function cannot corrupt memory (even when called from multiple 
threads), the comment is very misleading.
If the function cannot possibly be called from multiple threads (no idea 
how that would work), the comment is also misleading.


More information about the Digitalmars-d mailing list