static this sucks, we should deprecate it
jarrett.billingsley at gmail.com
Sun May 31 13:54:02 PDT 2009
On Sun, May 31, 2009 at 4:39 PM, Walter Bright
<newshound1 at digitalmars.com> wrote:
> The solution is relatively robust and straightforward. Create a third
> module, AB. Module A and module B both import AB. Put the static
> constructors for both A and B in module AB. The order of initialization
> problem is robustly solved, and all the interdependencies of initialization
> of A and B are explicitly laid out in AB.
If I might speak from personal experience, what usually ends up
happening instead is that A and B get merged into a single module.
This happens enough times, and you have half your code in one file.
The only way to avoid this is either to create circularly-importing
modules, which are considered bad practice (and also cause DMD's
forward reference bugs to rear their heads), or to completely refactor
your code, which is rarely an attractive option.
More information about the Digitalmars-d