shared switch

Imperatorn johan_forsberg_86 at hotmail.com
Sun Oct 8 06:27:20 UTC 2023


On Sunday, 8 October 2023 at 05:27:54 UTC, Nicholas Wilson wrote:
> On Saturday, 7 October 2023 at 09:26:09 UTC, Imperatorn wrote:
>> Regarding shared, why is preview=nosharedaccess not the 
>> default?
>
> because it break a bunch of stuff
>
>> Instead it could have been preview=sharedaccess.
>>
>> I thought the point was that you want protection, otherwise 
>> you would use __gshared?
>>
>> Input?
>
> The idea is that access to shared variables is unsafe.
> So in order to access them you need to do so through a @trusted 
> interface that does the appropriate thing (atomics, locks, 
> whatever).
> To force you to use the correct interface, 
> -preview=nosharedaccess forbids both reads and writes of shared 
> variables (hence no access) and so (in the implementation) you 
> must `cast()` (which is a safety violation), and so those 
> functions must be @trusted to be used from @safe code.

Thanks for the explanation.

I'm trying to explore what to do to get the maximum safety 
features for D.

Not only safety, but also "logical safety"

Like, @safe pure etc. Seems I should use nosharedaccess also then 
and probably dip1000, although we won't use pointers at all if 
possible.


More information about the Digitalmars-d mailing list