Assignment of shared values

Idan Arye via Digitalmars-d digitalmars-d at puremagic.com
Thu Aug 7 06:27:23 PDT 2014


On Thursday, 7 August 2014 at 12:45:12 UTC, Marc Schütz wrote:
> On Thursday, 7 August 2014 at 12:25:09 UTC, Dicebot wrote:
>> On Wednesday, 6 August 2014 at 23:01:11 UTC, Andrei 
>> Alexandrescu wrote:
>>> Somewhat sadly, this code does compile:
>>>
>>> shared S s1, s2;
>>> s1 = s2;
>>
>> I have no idea what semantics this may have from just reading 
>> the snippet. IMHO killing it will be a good thing and totally 
>> in line with your comments about shared you have made during 
>> DConf conversations.
>
> Should it be allowed if `S` defines `opAssign`?

Only if `S` defines a shared `opAssign`. In matter of fact, if 
`S` defines a non-shared `opAssign` without defining the shared 
version that code won't compile(which is probably why the 
`Variant` case doesn't compile).


More information about the Digitalmars-d mailing list