auto classes and finalizers

Bruno Medeiros brunodomedeirosATgmail at SPAM.com
Mon Apr 10 04:33:33 PDT 2006


Georg Wrede wrote:
> 
> If the above case was written as:
> 
>    class SomeUIWidget {
>      Color fgcolor;
>      Color bgcolor;
>      Size size;
>      Image image;
>      ...
> 
> and the class didn't have an explicit destructor, then the only "damage" 
> at GC (or otherwise destruction) time would be that a couple of Color 
> instances, a Size instance and an Image instance would be "left over" 
> after that particular GC run.
> 
> Big deal? At the next GC run (unless they'd be pointed-to by other 
> things), they'd get deleted too. No major flood of tears here.
> 
> Somehow I fear folks are making this a way too complicated thing.

Actually, with any decent GC, all of those objects will be reclaimed on 
the first GC run (and DMD does that). So you are correct that there is 
no difference when running the GC on that object.
But you miss the point. The point (of my suggestions) was to be able to 
have a destruction system that would work correctly both when called by 
a GC cycle, and when called explicitly (outside of a GC cycle).


-- 
Bruno Medeiros - CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D



More information about the Digitalmars-d mailing list