DIP 1024---Shared Atomics---Final Review

RazvanN razvan.nitu1305 at gmail.com
Wed Dec 11 11:21:22 UTC 2019


On Tuesday, 10 December 2019 at 15:26:02 UTC, Simen Kjærås wrote:
> On Tuesday, 10 December 2019 at 12:16:29 UTC, RazvanN wrote:
>> On Sunday, 8 December 2019 at 16:25:21 UTC, Mike Parker wrote:
>>
>> I think that it should be stated somewhere that the DIP makes 
>> shared unusable in betterC code.
>
> There's nothing stopping you from implementing your own 
> primitives for manipulating shared data in betterC - 
> core.atomic is only mentioned because it's the standard library 
> way to do it.
>

If you think from an implementation point of view, the compiler 
will most likely search for specific functions that can be called 
on shared variables (a finite list that contains only the 
functions defined in druntime). The only way you can override 
that is to define functions that have exactly the same name as 
the ones in druntime, but that is risky because the compiler does 
not have any way of verifying that you are actually synchronizing 
the access.


> It seems unlikely that core.atomic uses the features that 
> betterC disables, and where it does a betterC version should be 
> relatively easy to write. I expect this will be on dub within a 
> week of this being implemented, and if it isn't you can just 
> copy the parts you need from core.atomic.
>

Yes, the function in core atomic are templates, but if there are 
internal calls to non-templated functions you will end up with a 
link error.

> In short, using shared in betterC may be harder, but it's far 
> from unusable.
>
> --
>   Simen




More information about the Digitalmars-d mailing list