www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Re: Sharing in D

reply Jason House <jason.james.house gmail.com> writes:
Walter Bright Wrote:
 
 Unshared can be implicitly cast to shared, so you shouldn't have to.

That should not be implicit. For one, thread-local garbage collection of non-shared data would leave dangling references to garbage memory. Two, the guarantees for shared data are lost. Code using the non-shared reference will not respect that the variable really is shared.
Aug 01 2008
parent Walter Bright <newshound1 digitalmars.com> writes:
Jason House wrote:
 Walter Bright Wrote:
 
 Unshared can be implicitly cast to shared, so you shouldn't have
 to.

That should not be implicit. For one, thread-local garbage collection of non-shared data would leave dangling references to garbage memory.

True, but the memory allocation system shouldn't be (and isn't) built that way.
 Two, the guarantees for shared data are lost. Code using the
 non-shared reference will not respect that the variable really is
 shared.

That would be true if shared were implicitly cast to unshared, but that's not the case. It's unshared implicitly cast to shared.
Aug 01 2008