On Thursday, 15 January 2015 at 15:24:55 UTC, Ola Fosheim Grøstad
wrote:
I am trying to understand the idea behind "shared" typing fully.
If I am only allowed to share objects with another thread if it
is typed "shared", doesn't that imply that it should be
allocated as shared too and only be allowed to contain pointers
to "shared"?
Yes, shared is transitive.
struct S { int* p; }
void main() {
S s1;
shared S s2 = s1; // error, but ok if p is int.
}
That would be nice, because then a precise garbage collector
could choose between local collection scans and global
collection scans.
I think something like this is part of the plan, but shared
semantics are still up in the air.