GC does not delete subclass

Steven Schveighoffer schveiguy at yahoo.com
Tue Dec 18 12:45:22 PST 2007


"Sean Kelly" wrote
> I'm pretty sure that this is what's happening.  However, it is only 
> deleting C, not the objects that C points to.  This is necessary behavior. 
> Consider:
>
>     class A
>     {}
>     class B
>     {
>         this( A a )
>         {
>             val = a;
>         }
>         A val;
>     }
>
>     void fn( A val )
>     {
>         scope B = new B( val );
>     }
>
> You certainly wouldn't want the instance of A deleted when fn exits as 
> well.

Oh!  I misunderstood the original post.

Yes, I agree that the current behavior should be the expected behavior for 
the original example.

I thought that for some reason the destructor of the scoped class was not 
getting called when the scope exited.

-Steve 





More information about the Digitalmars-d mailing list