Assignment of shared values

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Thu Aug 7 10:20:59 PDT 2014


On 8/7/14, 10:12 AM, Sean Kelly wrote:
> On Wednesday, 6 August 2014 at 23:01:11 UTC, Andrei Alexandrescu wrote:
>> I'd submitted https://issues.dlang.org/show_bug.cgi?id=4130 which is
>> related to issues with shared values assignment.
>>
>> Consider:
>>
>> struct S { long a, b, c; ... }
>>
>> Should it be safe to assign one S to another? I guess not because
>> assignment would violate whatever invariant a, b, and c may hold, and
>> there's too much state to be assigned atomically.
>
> But isn't it required that structs allows bit copying?  Perhaps it's
> simply invalid to have a shared struct at all?  Which in turn suggests
> that naive transitivity of shared isn't correct.

Shared structs should be allowed, operations on them should follow the 
usual qualifier checks, and transitivity should follow the usual 
qualifier rules.

The problem at hand is assignment of shared structs is allowed - it 
shouldn't.


Andrei



More information about the Digitalmars-d mailing list