Hi,

class A{
  A parent;
  A[] items;

  void myDestroy(){
    items.each!(i => i.myDestroy);
    parent = null;
// after this point I think the GC will release it automatically, and it will call ~this() too. Am I right?
  }
}

I have a hierarchy of class instances forward and backward linked to its items ant its parent.

What is a proper way to destroy an instance of class A? Is calling instance.myDestroy sufficient?

Am I right that this kind of uninitialization MUST not go into the ~this() destructor, because of the references the instance is holding, the system will never call the ~this()?

Or is there a better way for this type of thing in Dlang?


Thanks in advance!

Reply via email to