On 2010-03-12 15:05:25 +0100, Michel Fortin <michel.for...@michelf.com> said:

[...]
Most mixins static constructors will probably have to be @cyclehead.

Here is an example of a reasonable use case to clarify why I think that my proposal, or something like it is the correct solution. Often the static initializers like those in module b or c would be mixed in (for example to give serialization support, as for example the class name in template classes is not unique).

{{{
module a;
// imports modules but does not create a circular dep

class Register {
 void register(...){...}
 ...
}

Register globalRegister;
static this(){
 globalRegister=new Register();
}

-------
module b;
import c;
import a;

class Bla {...}
@dependOnly(a) static this {
 globalRegister.register(...);
}
----
module c;
import b;
import a;

class Bla2 {...}
@dependOnly(a) static this {
 globalRegister.register(...);
}
}}}

My proposal would give the correct initialization order, and would still detect invalid cases (assuming the programmers does not lie about the dependOnly).

Fawzi

Reply via email to