March 29, 2009 [Issue 2770] New: Example code would help in Modules documentation | ||||
---|---|---|---|---|
| ||||
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: bugzilla@digitalmars.com ReportedBy: steve.teale@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); } -- |
Copyright © 1999-2021 by the D Language Foundation