On Tuesday, 3 May 2022 at 14:38:53 UTC, Arafel wrote:
Actually, it would be cool to do it through an interface,
although I don't think an interface's static constructors are
invoked by the implementing classes... it would be cool, though.
yeah interfaces can't have constructors.
I'd try it myself, but I wouldn't know where to start. Compiler
internals are way beyond my comfort zone...
Believe it or not, you don't need to touch the compiler. Open
your druntime's object.d and search for `RTInfo`
http://druntime.dpldocs.info/object.RTInfo.html
That is instantiated for every user defined type in the program
and you have the compile time info..... all druntime uses it for
is a tiny bit of GC info and even then only sometimes.
But it could do so so so much more. Including doing custom
factories and runtime reflection buildups!