Destruction Sequence: module and classes defined within

vano ivan.melnychuk+news at gmail.com
Tue Oct 5 14:25:36 PDT 2010


The code below:
     module used;

     import std.stdio;

     class ClassA {
         this()  { writeln("A ctor"); }
         ~this() { writeln("A dtor"); }
     }

     static this()  { writeln("used.sctor"); }
     static ~this() { writeln("used.sdtor"); }

     void main() {
         auto a = new ClassA();
     }
produces the following output (DMD v2.049):
     used.sctor
     A ctor
     used.sdtor
     A dtor

The question is: should the module be allowed to be unloaded before all 
module-level objects/structures are destructed/unloaded?


More information about the Digitalmars-d-learn mailing list