Semantics of casting **to** shared?

dsimcha dsimcha at yahoo.com
Sat Sep 4 12:50:57 PDT 2010


== Quote from Denis Koroskin (2korden at gmail.com)'s article
> I loved the recent clone() idea. I think it might be better to disable
> casting to (and from) shared (and immutable) and make a (deep?) copy of an
> object instead. This will make sure that the isn't any dangling reference
> left. I strongly believe dangling references could become a major source
> of bugs which might be hard to find and fix.

Holy %)(*$%, casting **to** immutable works in SafeD, too?  Of course casting
from/to shared/immutable should be allowed in non- at safe code, but I don't think
either should be allowed in @safe code.  The only way to get aliasing between
mutable and immutable data in @safe code should be by using broken @trusted code.
 Otherwise the @safe-ty of SafeD is really questionable.

Also, as far as cloning, The fact that it's really a special case of serialization
was brought up by a few people, so I'm taking a wait-and-see attitude and seeing
what people who wrote serialization libraries come up w/ for cloning, rather than
working on cloning now.


More information about the Digitalmars-d mailing list