Top 5
Bruno Medeiros
brunodomedeiros+spam at com.gmail
Wed Oct 15 05:32:10 PDT 2008
Adam D. Ruppe wrote:
>
> To fix it, what I think I'd like is a type modifier to make this ok.
>
> class A{
> SomeObject a;
> unmanaged SomeObject b; // my addon: tell the GC to not manage this object.
> ~this(){
> a.whatever(); // if the object is garbage collected, this might crash,
> // since the garbage collector might have already
> // deleted a. Thus, I think it should be a compiler
> // error to access it this way.
> // UNLESS, SomeObject is guaranteed to be
> // deleted deterministically, such as if it is a
> // scope class (or if it is unmanaged as well.)
> b.whatever(); // this, however, is safe in my proposed addition, since
> // b is marked unmanaged, meaning the garbage collector
> // leaves it alone.
> }
> }
>
Err, you can do this yourself by allocating b outside of the GC heap.
Might not be as safe as a solution integrated with the type system, but
it's possible.
--
Bruno Medeiros - Software Developer, MSc. in CS/E graduate
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
More information about the Digitalmars-d
mailing list