Bug 2770 – Example code would help in Modules documentation

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dlang.org
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2009-03-29T14:20:00Z
Last change time
2015-06-09T05:15:03Z
Assigned to
nobody
Creator
steve.teale

Comments

Comment #0 by steve.teale — 2009-03-29T14:20:43Z
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); }
Comment #1 by andrej.mitrovich — 2014-04-23T13:45:04Z
There are a few examples now.