What does D define for circular dependencies

Steven Schveighoffer schveiguy at yahoo.com
Tue Jun 26 10:35:08 PDT 2012


On Tue, 26 Jun 2012 13:27:00 -0400, Mehrdad <wfunction at hotmail.com> wrote:

> I realize this scenario might look stupid, but I hope the underlying  
> problem isn't.
>
> Does D define what happens in a situation like this?
>
>
> module a;
> import b;
> static if (!is(typeof(.b.foo))) int foo = 1;
>
>
> module b;
> import a;
> static if (!is(typeof(.a.foo))) int foo = 2;

I don't think it can.  D does runtime circular dependency checking at a  
very coarse level, but this is forcing static checking.  I think the  
compiler will throw a forward reference/recursion error in this case (and  
if it doesn't, it should).

-Steve


More information about the Digitalmars-d mailing list