digitalmars.D - Execution order of static ...
- ptkacz cogeco.ca (36/36) Aug 31 2004 I don't know if this has been discussed, but will bring it up. Reading ...
- Walter (3/3) Aug 31 2004 The static initialization does have an order. First, all imports are
- Sean Kelly (4/7) Aug 31 2004 Not to hijack the thread, but is it reasonable to assume that unit tests...
- Walter (5/12) Aug 31 2004 lexical
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.
Aug 31 2004
The static initialization does have an order. First, all imports are constructed first. Then the static initializers are executed in the lexical order in which they appear in the module.
Aug 31 2004
In article <ch302m$1b80$1 digitaldaemon.com>, Walter says...The static initialization does have an order. First, all imports are constructed first. Then the static initializers are executed in the lexical order in which they appear in the module.Not to hijack the thread, but is it reasonable to assume that unit tests are ordered the same way? Sean
Aug 31 2004
"Sean Kelly" <sean f4.ca> wrote in message news:ch3153$1bng$1 digitaldaemon.com...In article <ch302m$1b80$1 digitaldaemon.com>, Walter says...lexicalThe static initialization does have an order. First, all imports are constructed first. Then the static initializers are executed in theareorder in which they appear in the module.Not to hijack the thread, but is it reasonable to assume that unit testsordered the same way?Yes.
Aug 31 2004