more cyclical confoundedness
Ellery Newcomer
ellery-newcomer at utulsa.edu
Wed Apr 8 20:14:26 PDT 2009
Och, I feel so alone. I'll rephrase the question:
How is a cyclic dependency defined? Is it a cycle formed by imports in
which two or more of the modules contain static constructors?
The reason I ask is because I'm trying to mechanize finding these cyclic
dependencies, and my example suggests that the above assumption will
generate a large proportion of false positives, or else the compiler
ignores a large proportion of true positives.
Ellery Newcomer wrote:
> Hello.
>
> When I have three files test1.d test2.d test3.d as follows:
>
> module test1;
> import tango.io.Stdout;
> import test3;
> static this(){
> Stdout("test1\n");
> }
>
>
> module test2;
> import test1;
> //no ctor
>
>
> module test3;
> import tango.io.Stdout;
> import test2;
> static this(){
> Stdout("test3\n");
> }
>
>
> and main.d:
>
> module main;
> import tango.io.Stdout;
> import test1;
> import test2;
> import test3;
> main(){}
> static this(){
> Stdout("main\n");
> }
>
>
> It works dandy, compiling AND running to give me
>
> test3
> test1
> main
>
> But if I change the import order to begin with
>
> import test3;
>
> it barfs with the cyclic dependency runtime error. All other
> combinations give output same as the first.
>
> Now, what the heck is going on? As near as I can tell these should all
> fail at runtime. Or am I missing something?
More information about the Digitalmars-d-learn
mailing list