On Monday, 31 October 2016 at 04:35:35 UTC, WhatMeWorry wrote:
First, are there any other languages that has this feature? The few I know, certainly don't.
I've seen hacks to do the same thing in C++. They're not pretty, though.
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?
Class/struct static constructors are good for initialising class/struct static data. Module static constructors are good for initialising module "static data" (i.e., globals). They're especially handy for initialising immutable global data (which is the kind of global data D encourages).
BTW, immutable data is shared between threads, so you should use "shared static this" to initialise it. Regular static constructors are executed per thread.