http://d.puremagic.com/issues/show_bug.cgi?id=2770
Summary: Example code would help in Modules documentation Product: D Version: 2.026 Platform: PC OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzi...@digitalmars.com ReportedBy: steve.te...@britseyeview.com For instance: module example; import std.stdio; template factorial(int n) { static if (n == 1) enum { factorial = 1 } else enum { factorial = n* factorial!(n-1) } } int _mmm; static this() { writefln("module initializing"); _mmm = factorial!(4); // If you uncomment the throw, then the static destructor will not get // called. // throw new Exception("What happened"); } static ~this() { writefln("Gone now"); } void main() { writefln(_mmm); } --