www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Forward reference wheel.

reply Dawid =?UTF-8?B?Q2nEmcW8YXJraWV3aWN6?= <dawid.ciezarkiewicz gmail.com> writes:
It's probably well known issue:

$ cat test.d
import test2;
 
class X {
        Y.NY t;
        static class NX {
        }
}
 
 
$ cat test2.d
import test;
 
class Y {
        X.NX nx;
        static class NY {
        }
}
 
 
$ dmd -c test2.d test.d
test2.d(3): class test2.Y is forward referenced when looking for 'NY'
test2.d(3): class test2.Y is forward referenced when looking for 'NY'
(...)
 
dpc empire:~/stg/tmp$ dmd -c test.d test2.d
test.d(3): class test.X is forward referenced when looking for 'NX'
test.d(3): class test.X is forward referenced when looking for 'NX'
(...)


What I'd like to ask is: "How should I consider this?" to know what should
do with this problem in my code.
A) it's not a bug - it's just little limitation - things shall stay like
this;
B) it an issue, but it will not be fixed sooner than > 1.0;
C) stay tuned, it surly be ready sooner than 1.0;
D) it's fixed already - wait for 0.150 or maybe just little longer.
E) you n00b! you can resolve this already without code modification by
doing: (...);

Thanks,
Dawid
Mar 10 2006
parent reply Chris Sauls <ibisbasenji gmail.com> writes:
Dawid Ciężarkiewicz wrote:
 It's probably well known issue:
 
 $ cat test.d
 import test2;
  
 class X {
         Y.NY t;
         static class NX {
         }
 }
  
  
 $ cat test2.d
 import test;
  
 class Y {
         X.NX nx;
         static class NY {
         }
 }
  
  
 $ dmd -c test2.d test.d
 test2.d(3): class test2.Y is forward referenced when looking for 'NY'
 test2.d(3): class test2.Y is forward referenced when looking for 'NY'
 (...)
  
 dpc empire:~/stg/tmp$ dmd -c test.d test2.d
 test.d(3): class test.X is forward referenced when looking for 'NX'
 test.d(3): class test.X is forward referenced when looking for 'NX'
 (...)
 
 
 What I'd like to ask is: "How should I consider this?" to know what should
 do with this problem in my code.
 A) it's not a bug - it's just little limitation - things shall stay like
 this;
 B) it an issue, but it will not be fixed sooner than > 1.0;
 C) stay tuned, it surly be ready sooner than 1.0;
 D) it's fixed already - wait for 0.150 or maybe just little longer.
 E) you n00b! you can resolve this already without code modification by
 doing: (...);
 
 Thanks,
 Dawid
 
 
 

E) I think. I believe you should be able to avoid this by changing `import test;` to `private import test;` and likewise for the `import test2;` in the other module. The private mode import will stop some cycles. -- Christopher Nicholson-Sauls
Mar 11 2006
parent Lars Ivar Igesund <larsivar igesund.net> writes:
Chris Sauls wrote:

 Dawid Ciężarkiewicz wrote:
 It's probably well known issue:
 
 $ cat test.d
 import test2;
  
 class X {
         Y.NY t;
         static class NX {
         }
 }
  
  
 $ cat test2.d
 import test;
  
 class Y {
         X.NX nx;
         static class NY {
         }
 }
  
  
 $ dmd -c test2.d test.d
 test2.d(3): class test2.Y is forward referenced when looking for 'NY'
 test2.d(3): class test2.Y is forward referenced when looking for 'NY'
 (...)
  
 dpc empire:~/stg/tmp$ dmd -c test.d test2.d
 test.d(3): class test.X is forward referenced when looking for 'NX'
 test.d(3): class test.X is forward referenced when looking for 'NX'
 (...)
 
 
 What I'd like to ask is: "How should I consider this?" to know what
 should do with this problem in my code.
 A) it's not a bug - it's just little limitation - things shall stay like
 this;
 B) it an issue, but it will not be fixed sooner than > 1.0;
 C) stay tuned, it surly be ready sooner than 1.0;
 D) it's fixed already - wait for 0.150 or maybe just little longer.
 E) you n00b! you can resolve this already without code modification by
 doing: (...);
 
 Thanks,
 Dawid
 
 
 

E) I think. I believe you should be able to avoid this by changing `import test;` to `private import test;` and likewise for the `import test2;` in the other module. The private mode import will stop some cycles. -- Christopher Nicholson-Sauls

That won't help, he is forward referencing a type in the other module from both the modules.
Mar 11 2006