www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - how to avoid infinite import?

reply clayasaurus <clayasaurus gmail.com> writes:
hello, i have two modules, lets say module A and B

------------------------
module A;

import B;

B.func();
------------------------

------------------------
module B;

import A;

A.func();
------------------------

i'm pretty sure that when i compile it,... it never stops compiling from 
the infinite import recursion. Both modules need the functions in the 
other module. How can I avoid this? do i just make it into one module?
Thanks.
Nov 08 2004
next sibling parent reply Bastiaan Veelo <Bastiaan.N.Veelo ntnu.no> writes:
clayasaurus wrote:
 hello, i have two modules, lets say module A and B
 
 ------------------------
 module A;
 
 import B;
 
 B.func();
 ------------------------
 
 ------------------------
 module B;
 
 import A;
 
 A.func();
 ------------------------
 
 i'm pretty sure that when i compile it,... it never stops compiling from 
 the infinite import recursion. Both modules need the functions in the 
 other module. How can I avoid this? do i just make it into one module?
 Thanks.

Try it. D is smarter than you think :-) Bastiaan.
Nov 08 2004
parent reply clayasaurus <clayasaurus gmail.com> writes:
i have two very big classes that are doing this with global class 
variables. I compile it and it never stops.

Bastiaan Veelo wrote:
 clayasaurus wrote:
 
 hello, i have two modules, lets say module A and B

 ------------------------
 module A;

 import B;

 B.func();
 ------------------------

 ------------------------
 module B;

 import A;

 A.func();
 ------------------------

 i'm pretty sure that when i compile it,... it never stops compiling 
 from the infinite import recursion. Both modules need the functions in 
 the other module. How can I avoid this? do i just make it into one 
 module?
 Thanks.

Try it. D is smarter than you think :-) Bastiaan.

Nov 08 2004
next sibling parent reply clayasaurus <clayasaurus gmail.com> writes:
nevermind. it never finishes compiling for some other reason :-/

clayasaurus wrote:
 i have two very big classes that are doing this with global class 
 variables. I compile it and it never stops.
 
 Bastiaan Veelo wrote:
 
 clayasaurus wrote:

 hello, i have two modules, lets say module A and B

 ------------------------
 module A;

 import B;

 B.func();
 ------------------------

 ------------------------
 module B;

 import A;

 A.func();
 ------------------------

 i'm pretty sure that when i compile it,... it never stops compiling 
 from the infinite import recursion. Both modules need the functions 
 in the other module. How can I avoid this? do i just make it into one 
 module?
 Thanks.

Try it. D is smarter than you think :-) Bastiaan.


Nov 08 2004
parent reply clayasaurus <clayasaurus gmail.com> writes:
ok. well i just found out that it does compile eventually. it just takes 
a really long time. it took so long i assumed it was some infinite 
problem. takes about 10-20 sec to compile a single .d file.

clayasaurus wrote:
 nevermind. it never finishes compiling for some other reason :-/
 
 clayasaurus wrote:
 
 i have two very big classes that are doing this with global class 
 variables. I compile it and it never stops.

 Bastiaan Veelo wrote:

 clayasaurus wrote:

 hello, i have two modules, lets say module A and B

 ------------------------
 module A;

 import B;

 B.func();
 ------------------------

 ------------------------
 module B;

 import A;

 A.func();
 ------------------------

 i'm pretty sure that when i compile it,... it never stops compiling 
 from the infinite import recursion. Both modules need the functions 
 in the other module. How can I avoid this? do i just make it into 
 one module?
 Thanks.

Try it. D is smarter than you think :-) Bastiaan.



Nov 08 2004
parent John Reimer <John_member pathlink.com> writes:
In article <cmo5mn$t5i$1 digitaldaemon.com>, clayasaurus says...
ok. well i just found out that it does compile eventually. it just takes 
a really long time. it took so long i assumed it was some infinite 
problem. takes about 10-20 sec to compile a single .d file.

Hmmm... might be similar to the problem DWT is experiencing... except that the DWT compilation eventually crashes dmd with an "out of memory" error.
Nov 08 2004
prev sibling parent Bastiaan Veelo <Bastiaan.N.Veelo ntnu.no> writes:
clayasaurus wrote:
 i have two very big classes that are doing this with global class 
 variables. I compile it and it never stops.

I don't have D here at the moment, but my project has an import loop and it used to compile. Have not tried the latest releases though. I use private import, but that should not matter much. Bastiaan.
Nov 08 2004
prev sibling parent Ant <Ant_member pathlink.com> writes:
In article <cmo1i9$mi5$1 digitaldaemon.com>, clayasaurus says...
hello, i have two modules, lets say module A and B

------------------------
module A;

import B;

B.func();
------------------------

------------------------
module B;

import A;

A.func();
------------------------

i'm pretty sure that when i compile it,... it never stops compiling from 
the infinite import recursion. Both modules need the functions in the 
other module. How can I avoid this? do i just make it into one module?
Thanks.

Nov 08 2004