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...