shared - i need it to be useful

Stanislav Blinov stanislav.blinov at gmail.com
Thu Oct 18 18:42:22 UTC 2018


On Thursday, 18 October 2018 at 18:26:27 UTC, Steven 
Schveighoffer wrote:
> On 10/18/18 1:47 PM, Stanislav Blinov wrote:
>> On Thursday, 18 October 2018 at 17:17:37 UTC, Atila Neves 
>> wrote:
>>> On Monday, 15 October 2018 at 18:46:45 UTC, Manu wrote:
>>>> 1. shared should behave exactly like const, except in 
>>>> addition to inhibiting write access, it also inhibits read 
>>>> access.
>>>
>>> How is this significantly different from now?
>>>
>>> -----------------
>>> shared int i;
>>> ++i;
>>>
>>> Error: read-modify-write operations are not allowed for 
>>> shared variables. Use core.atomic.atomicOp!"+="(i, 1) instead.
>>> -----------------
>>>
>>> There's not much one can do to modify a shared value as it is.
>> 
>> i = 1;
>> int x = i;
>> shared int y = i;
>
> This should be fine, y is not shared when being created.

'y' isn't, but 'i' is. It's fine on amd64, but that's incidental.


More information about the Digitalmars-d mailing list