On Sunday, 23 February 2020 at 14:36:56 UTC, Johan Engelen wrote:
It's not clear from the language specification, but in this case with templates, I am not surprised that the order of execution is not the same as in the source file. Probably it does fit with the order in the source file if you take into account where the template is instantiated in that file (but you shouldn't depend on that). I strongly recommend not to depend on the order of multiple static this execution, by either rewriting things or by including some logic to make sure things are called in the right order (checking that something has already run, and running it if not, or cancel running it if it already ran)

-Johan

This is generated code, so all defs are already topo-sorted. The template is instantiated before it's used, and in the .d.cg file it's also seemingly in the expected order. I'd be happy to put all initialisation code into a single static this(), but I'm not sure how to do that when templates get involved. Since it's generated code, the set of things that are easy/hard to do kinda swap around.

Reply via email to