QtD 0.1 is out!

Lars Ivar Igesund larsivar at igesund.net
Sat Feb 28 09:27:51 PST 2009


Eldar Insafutdinov wrote:

> Lars Ivar Igesund Wrote:
> 
>> Eldar Insafutdinov wrote:
>> 
>> > We faced a bug that module static constructors don't work with cyclic
>> > imports. Currently it's fixed with a dirty hack which is not really
>> > acceptable. Is there any chance for this to be fixed?
>> 
>> IMO it is the cyclic import that is the bug ;)
>> 
>> --
>> Lars Ivar Igesund
>> blog at http://larsivi.net
>> DSource, #d.tango & #D: larsivi
>> Dancing the Tango
>> 
> 
> I am not an expert but, Qt is a good example in my opinion, beause it is a
> mature API (fourth version)  which shows that you can't go without cyclic
> dependencies in a very complex project.

I do not agree that this proves anything. My opinion is that a circular 
dependency at the very least is a hazardous design decision. In a class 
hierarchy this may work out well if there never ever will be any sub-classes 
to the involved classes, but typically this will come back and bite you in 
the toe when you cannot afford to redesign.

I know D is less forgiving about this than other languages, and so it is a 
good help in creating a good design. Note that Java allows circular import 
dependencies, but not class dependencies at construction time (instance 
variables initialised prior to the constructor being run) which is similar 
to the static construction restriction in D.

I understand that your issue is due to Qt's design and not your own, and as 
such the compiler could be more helpful, but in general I think the compiler 
should flag this at least at warning level (I agree with those who think it 
should be a compile time rather than a runtime error).

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



More information about the Digitalmars-d-announce mailing list