On Wednesday, 10 June 2015 at 06:55:43 UTC, Walter Bright wrote:
On 6/9/2015 10:39 PM, deadalnix wrote:
The actual code is far more complex than the presented sample :)

That what I'm trying to do in general, but here I'm faced with cases that are
very hard to untangle.

The 'tangle' of cyclical import graphs, as you so appropriately put, is not only hard on the compiler, it makes it much harder for human readers to make sense of code. Even reading your little code snippet hurts my brain.

Go, in one of their better decisions, decided "Thou Shalt Not Have Import Cycles". This forces users to untangle their code, and I believe that is A Good Thing.

I'd like to do that for D, but of course it is far too late for that.

Ada (83 and 95) were also rigid about not allowing any kind of import cycles. At some point, probably after Ada 95 when OO was added, it was decided after much experience that there were some cases where it was better to allow it. If you're interested, in the Ada world this issue was dubbed "the with-ing problem" and a quick Google search gives

http://www.ada95.ch/doc/within/FAQ.html#what

http://www.adaic.org/resources/add_content/standards/05rat/html/Rat-4-2.html

also in the world of Haskell, this thread

https://mail.haskell.org/pipermail/haskell-cafe/2004-September/006885.html

and I'm sure in many other places too.

I agree with you, Walter, that mutual recursion amongst imports is usually bad, but I think you inadvertently made the right decision by allowing it in D, and that the bug should be fixed. If people overuse it to write messy code then the community should tell them to write that code better.



Reply via email to