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

Max Samukha spambox at d-coding.com
Wed Mar 10 10:39:12 PST 2010


On 10.03.2010 13:13, Walter Bright wrote:
> Walter Bright wrote:
>> Max Samukha wrote:
>>> 2. A third module cannot be used. At least, we haven't been able to
>>> figure out how to do that. Probably, something could be hacked up if
>>> this bug (feature) is fixed
>>> http://d.puremagic.com/issues/show_bug.cgi?id=2671
>>
>> Thanks, I'll have a look at it.
>
> The example in the bug report works on D1 and D2. I cannot reproduce the
> error. I marked it as "worksforme"; if I've got the test case wrong
> please reopen it.

My example is incorrect, sorry. b and c should be circularly imported:

module a;

template Foo(int i)
{
     static this()
     {
     }
}

void main() { }
----

module b;

import a;
import c;

alias Foo!(1) foo;
----

module c;

import a;
import b;

alias Foo!(2) foo;
----
Error: circular initialization dependency with module b

Following the logic that Foo is not a mixin template, I hoped to cheat 
the compiler so that the static constructors ran during a's 
initialization, avoiding the circular dependency error. I was wrong.

Still looking for a solution. Basically, there should be a way to enable 
the following:

module a;

template Foo()
{
     static int a;
     static this()
     {
        a = 42;
     }
}

----
module b;
import c;
import a;

mixin Foo;

----
module c;
import b;
import a;

mixin Foo;






More information about the Digitalmars-d mailing list