implicit conversions to/from shared

ag0aep6g via Digitalmars-d digitalmars-d at puremagic.com
Tue Jul 12 05:47:05 PDT 2016


On 07/12/2016 02:26 PM, Kagamin wrote:
> On Monday, 11 July 2016 at 13:54:49 UTC, ag0aep6g wrote:
>> If I got that right: Sure. But the compiler can't know if a shared
>> variable is volatile or not, so it has to assume that it is. If the
>> programmer knows that it's not volatile, they can cast shared away and
>> use a normal load.
>
> If you cast shared away, an unshared postblit will be called instead of
> shared one.

True. One would have to watch out for that, and maybe work around 
correspondingly. The cast would be a greppable indicator that special 
care is needed. In contrast, unsafe reading/writing of shared data that 
looks like just another assignment is similarly problematic and harder 
to spot.

If reading/writing shared directly would be disallowed completely 
(always have to use core.atomic or cast), then shared postblits wouldn't 
make sense anymore, I guess.


More information about the Digitalmars-d mailing list