shared - i need it to be useful
Nicholas Wilson
iamthewilsonator at hotmail.com
Wed Oct 17 13:58:27 UTC 2018
On Wednesday, 17 October 2018 at 13:25:28 UTC, Steven
Schveighoffer wrote:
> On 10/16/18 8:26 PM, Manu wrote:
>> On Tue, Oct 16, 2018 at 2:20 PM Steven Schveighoffer via
>> Digitalmars-d
>> <digitalmars-d at puremagic.com> wrote:
>>> There is in fact, no difference between:
>>>
>>> int *p;
>>> shared int *p2 = p;
>>> int *p3 = cast(int*)p2;
>>
>> Totally illegal!! You casted away shared. That's as bad as
>> casting away const.
>
> But if you can't do anything with shared data, how do you use
> it?
>
>>
>>> and this:
>>>
>>> int *p;
>>> shared int *p2 = p;
>>> int *p3 = p;
>>
>> There's nothing wrong with this... I don't understand the
>> point?
>
> It's identical to the top one. You now have a new unshared
> reference to shared data. This is done WITHOUT any agreed-upon
> synchronization.
It isn't, you typo'd it (I originally missed it too).
> int *p3 = cast(int*)p2;
vs
> int *p3 = p;
More information about the Digitalmars-d
mailing list