QtD 0.1 is out!

Fawzi Mohamed fmohamed at mac.com
Sat Feb 28 11:56:43 PST 2009


On 2009-02-28 14:54:26 +0100, Christopher Wright <dhasenan at gmail.com> said:

> Lutger wrote:
>> grauzone 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 ;)
>>> Maybe all cyclic dependency bugs are on purpose, to teach people not to 
>>> use this evil D feature? Yeah, that must it be. I can't explain why 
>>> else these bugs/issues aren't fixed, and why people only reply with 
>>> incredibly useful statements like "but you shouldn't use this feature 
>>> anyway!".
>>> 
>>> Broken features should be either fixed or removed. This half-assedness 
>>> about it isn't really going to help D.
>> 
>> Well it's about cyclic dependency of initialization via module 
>> constructors only right? Cyclic imports in general aren't (supposed to 
>> be) broken, nor are module constructors.
>> 
> 
> And in point of fact, you can modify the runtime so it will not throw 
> exceptions on cyclic dependencies:
> 
> Index: genobj.d
> ===================================================================
> --- genobj.d    (revision 4339)
> +++ genobj.d    (working copy)
> @@ -1098,11 +1098,7 @@
>           if (m.ctor || m.dtor)
>           {
>               if (m.flags & MIctorstart)
> -            {   if (skip || m.flags & MIstandalone)
> -                    continue;
> -                throw new Exception( "Cyclic dependency in module " ~ 
> (from is null ? "*null*" : from.name) ~ " for import " ~ m.name);
> -            }
> -
> +               continue;
>               m.flags |= MIctorstart;
>               _moduleCtor2(m,m.importedModules, 0);
>               if (m.ctor)
> 
> This opens you up to certain bugs, but they should be relatively rare.
> 
> I've tried it, and it appears to work.

Tango has it (thanks to lindquist) your change removes it :)



More information about the Digitalmars-d-announce mailing list