Fixing cyclic import static construction problems

Jonathan M Davis jmdavisProg at gmx.com
Thu Nov 29 19:23:41 PST 2012


On Friday, November 30, 2012 03:10:57 Manfred Nowak wrote:
> Timon Gehr wrote:
> > what module reflect imposes
> 
> Thank you.
> 
> It seems to be true then, that no issue would be generated if
> the compiler assumes, that Walters pragma is existent in every
> module.

So, you're suggesting that the runtime should just not worry about circular 
dependencies between modules at all? What if you have something like

module a;
import b;

immutable Foo foo;
shared static this()
{
 foo = new immutable(Foo)(bar);
}

module b;
import a;

immutable Bar bar;
shared static this()
{
 bar = new immutable(Bar)(foo);
}

That's a true circular dependency. It's a big problem if that's allowed. D 
rightly disallows it. The problem is that in the vast majority of cases, there 
is no such circular dependency, so the circular dependency detection disallows 
many valid use cases.

Or do you mean something else by the suggestion that the existence of Walter's 
pragma can be assumed? I don't know what else you could mean other than
suggesting that assuming that it's present in all modules which is the same
as throwing away circular dependency detection entirely.

- Jonathan M Davis


More information about the Digitalmars-d mailing list