general questions about static this() at module level

WhatMeWorry via Digitalmars-d-learn digitalmars-d-learn at
Sun Oct 30 21:35:35 PDT 2016

I am fascinated with D's module static this.

I have shamelessly stolen Ali's code directly from his book.

module cat;

static this() {
// ... the initial operations of the module ...
static ~this() {
// ... the final operations of the module ...

First, are there any other languages that has this feature?  The 
few I know, certainly don't.

And how would you compare and contrast these this(s) with those 
of structs and classes?
Like, are they especially good for certain D idioms, particular 
cases, or are they good in general?

Thirdly, can anyone point to existing code for good examples.

I searched on github for "static this" and 10,499 results were 
returned :)

More information about the Digitalmars-d-learn mailing list