Assignment of shared values

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Wed Aug 6 16:01:10 PDT 2014


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. Somewhat sadly, this 
code does compile:

shared S s1, s2;
s1 = s2;

However, assigning Variant objects holding such structs does not 
compile, which in turn leads to the reported bug in std.concurrency. Now 
it seems to me that the only way is to adapt Variant to allow such 
assignments, otherwise we'd be breaking existing code. Thoughts appreciated.


Andrei


More information about the Digitalmars-d mailing list