any tool to at least partially convert C++ to D (htod for source

Ellery Newcomer ellery-newcomer at utulsa.edu
Tue Mar 9 15:32:08 PST 2010


On 03/09/2010 03:35 PM, Justin Johansson wrote:
> #3 problems with circular module references.  I forget some of the detail but think, if I
> recall correctly, that it was to do with static class members so had to pull a lot of source
> code into one big file .. then leading to problem #4
>
>
> Justin Johansson
>

I hate the restriction on modules with static constructors and cyclic 
dependencies. IMO it's the most patronizing 'feature' D has. A year or 
so ago I ran into this issue during my first (and last) big project in 
D. Just last week I started working on it again and replaced everything 
that got initialized in a static constructor with stuff akin to

static Foobar foobar(){
   static Foobar _foobar;
   static bool inited = false;
   if(!inited){
     _foobar = new Foobar();
     _foobar.init();
     inited = true;
   }
   return _foobar;
}


(on a side note, string mixins are turning out to be quite handy)

It killed the cyclic dependency problems, but I expect this pattern 
isn't a good thing to have littered all over the place.




More information about the Digitalmars-d mailing list