Cyclic Dependencies

Lars Ivar Igesund larsivar at igesund.net
Tue Dec 9 02:35:16 PST 2008


Ellery Newcomer wrote:

> Hello all,
> 
> I began learning D a few months ago, and now I have a question about
> cyclic dependencies (and some random whining).
> 
> I come from a java background and have had no serious exposure to C++.
> In java, cyclic dependencies are legit to the best of my knowledge.

Legit in the way that they usually work - something that IMO cause a lot of Java code to be badly designed (causing too tight coupling and difficulties with extending code).

> I
> don't know about C++, thus I don't know about D.
> 
> When I first started learning D I decided that a good way to learn it
> would be by porting a popular java api (mind, I didn't say intelligent),
> which came complete with a few cyclic dependencies. At the moment, I'm
> using GDC, and it refuses to swallow cyclic dependencies. The compiler
> doesn't complain, but it throws a runtime exception. I can break the
> dependency loops and GDC will work just fine, but what I'm wondering is
> whether it is standard that the dependency hierarchy be acyclic, or is
> this some quirk of GDC, or is it more likely that there is something
> weird going on in my java-to-D translation.

No quirk, just good design sense. There are also some real cyclic issues in chicken-egg situations.

> Also, I would be trying to compile with DMD, but I have evidently
> managed to crash the compiler, and I don't know if it's DMD's fault or
> mine. It reports an Internal Error in e2ir.c at line 3904. (not being a
> C++ guru, the line "assert(n2->Enumbytes);" doesn't mean much to me)
> That was with DMD 1.037, Tango 0.997, and using dsss to build.

Tango 0.99.7 doesn't support DMD 1.037 - either use DMD 1.033 or check out Tango trunk.

-- 
Lars Ivar Igesund
blog at http://larsivi.net
DSource, #d.tango & #D: larsivi
Dancing the Tango


More information about the Digitalmars-d-learn mailing list