Steven Schveighoffer wrote:
On Thu, 28 May 2009 13:59:10 -0400, Ary Borenszweig <a...@esperanto.org.ar> wrote:

Is there something wrong in my reasoning?

It's just that you aren't always compiling every file at the same time...

Static this' implementation isn't part of the public interface, so it might not even *be* in the import file (if it's a .di file). Where do you throw the compiler error, if you can't determine the circular reference at comiple time?

I think with the import system the way it is, the only safe prospect is to have it error like it does now. You either need some attribution like has been suggested in this thread (and have the compiler verify that attribution), or change the import system.

The compiler could examine the symbols used in the static constructors to build these dependency lists. Then it's a matter of assembling a graph and checking for cycles. Each ModuleInfo would reference the modules its static constructors depend on in addition to the ones it imports. This would be used by the runtime to determine the proper order in which to call static constructors.

As a first step, the compiler could mark a module as having static constructors. Then the cycle detection could happen at compile time rather than runtime. The sooner you detect errors, the better.

Reply via email to