| |
| Posted by ptkacz | PermalinkReply |
|
ptkacz
| I don't know if this has been discussed, but will bring it up. Reading the D specification, I have read that static constructors (and initialization of variables) are executed (or initialized) prior to the execution of main in no particular order.
How about modifying the "static" specifier to allow for execution order in the following manner:
static(int order) ...
1) "static" without any parameters would be treated as normal.
2) a parameter specified would be an integer value (negative, zero, or
positive).
3) "static specifiers with a specified parameter would be executed first,
followed by "static" specifiers with no parameter, followed by the execution of
main.
4) the integer parameter to a "static" specifier would indicate execution order.
Excution would start with the "static" specifier having the smallest value,
followed by the next "static" spcifier having the next larger value.
5) "static" specifiers with the same order parameter would be executed in what
ever order they come.
So for example,
class Meow
{
static(5) this() {....}
}
class Bark
{
static(1) this() {...}
}
class Hoot
{
static this() {...}
}
Execution order would then be: Bark.this(), Meow.this(), Hoot.this()...
main()...
Peter
P.S. If I've not made sense, it's it's because I've been looking too hard at the computer screen at work all day.
|