On Monday, 7 June 2021 at 11:31:13 UTC, tastyminerals wrote:
It's interesting how there is no information about class instantiation at module level anywhere in the docs. Even the Ali's book does not explicitly say that you cannot instantiate a class this way. Maybe I totally missed it but just doing the key search on "scope", "global", "module" in class related chapters didn't give me any results.
It's covered by this: https://dlang.org/spec/declaration.html#global_static_init
The Initializer for a global or static variable must be evaluatable at compile time. Runtime initialization is done with static constructors.
It obviously could be more explicit. I'll add a note to my todo list to make it so.