Argh!! Cyclic dependencies!!!
Jason House
jason.james.house at gmail.com
Fri Mar 18 16:24:41 PDT 2011
Nick Sabalausky Wrote:
> These module constructor "Cyclic dependencies" errors are really starting to
> piss me off. I feel like I'm back in the days when you'd sneeze and DMD
> would vomit out 100 forward reference errors just because you didn't write
> your whole damn app in one giant ultra-module. (/me takes a breather to
> chill out...Ok...)
>
> I don't suppose there's any chance we could get a quick little:
>
> import foo;
>
> pragma(staticCtorsAvoid, foo);
> // Or
> pragma(staticCtorsRunBefore, foo);
> // Or
> pragma(staticCtorsRunAfter, foo);
>
> static this()
> {
> // do trivial shit that doesn't touch foo
> }
>
Could module-level globals be treated like local variables to the static constructor for the purpose of checking purity?
AKA
static this() pure
{
// trivial stuff
// calls weakly pure functions
// writes module-level globals
// reads module-level globals
// etc...
}
That's compiler enforceable and effectively means that stati constructor does not count as part of a cyclic dependency...
More information about the Digitalmars-d
mailing list