DMD 1.038 and 2.022 releases

naryl cyNOSPAM at ngs.ru
Sun Dec 21 14:34:00 PST 2008


Yigal Chripun Wrote:
> Nick Sabalausky wrote:
> > This might be a naive idea, and wouldn't solve the problems with cyclic
> > dependancies in the general case: But regarding the static initializaton
> > issue (which I've come up against myself), what if static initializers
> > allowed some sort of clause like this:
> >
> > module foo;
> > import bar;
> >
> > // Exact syntax not really important right now
> > this() dependsOn(bar) {
> >      // Do some initing that depends on
> >      // bar's static initializer having been run.
> > }
> >
> > That would force foo's static initialization to be run sometime after bar's.
> > Obviously, any cycles in the graph of "dependsOn"s would be an error.
> >
> >
> 
> I'm curios - why isn't this a problem in other languages like Java (and 
> I assume .net languages as well)?
> What's different in D that makes this so dificult? the static 
> initializers? How is this handled in other languages?

In Java static initializers are run during class loading. So cyclic dependencies in imports is not a problem. It's an error to make two or more static initializers depend on each other though.


More information about the Digitalmars-d-announce mailing list