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 :)

Reply via email to