D - Circular Imports
- Deja Augustine (18/18) Mar 18 2003 I was curious what happens in the following situation:
- Burton Radons (13/37) Mar 18 2003 D, unlike C, splits semantic phases into a set of stages. In the
- Deja Augustine (17/54) Mar 18 2003 exactly
- Burton Radons (3/20) Mar 18 2003 Yes, because they're classes. If they were struct, it would be a
- Deja Augustine (6/26) Mar 18 2003 can
I was curious what happens in the following situation: a.d --- import b; class A { B x; } --- b.d --- import a; class B { A x; } it didn't generate any compile-time errors, so I'm wondering what exactly happens with it.
Mar 18 2003
Deja Augustine wrote:I was curious what happens in the following situation: a.d --- import b; class A { B x; } --- b.d --- import a; class B { A x; } it didn't generate any compile-time errors, so I'm wondering what exactly happens with it.D, unlike C, splits semantic phases into a set of stages. In the initial parsing it sees B and A fields in one and the other and doesn't try to interpret it; it's only in the semantic phases that it links them together. It should also be possible to do this: class B : A { } class A { } And this: class A { B x; } struct B { } And this: A x = { 1, 2 }; struct A { int a, b; }
Mar 18 2003
"Burton Radons" <loth users.sourceforge.net> wrote in message news:b595vf$25cs$1 digitaldaemon.com...Deja Augustine wrote:exactlyI was curious what happens in the following situation: a.d --- import b; class A { B x; } --- b.d --- import a; class B { A x; } it didn't generate any compile-time errors, so I'm wondering whatYeah, that's not really what I was asking. What I wanted to know was, can someone, using my initial example, write a chunk of code like so: ----- c.d ----- import a; B var; int main() { var.x = new A(); var.x.x = new B(); var.x.x.x = new A(); } on into infinityhappens with it.D, unlike C, splits semantic phases into a set of stages. In the initial parsing it sees B and A fields in one and the other and doesn't try to interpret it; it's only in the semantic phases that it links them together. It should also be possible to do this: class B : A { } class A { } And this: class A { B x; } struct B { } And this: A x = { 1, 2 }; struct A { int a, b; }
Mar 18 2003
Deja Augustine wrote:Yeah, that's not really what I was asking. What I wanted to know was, can someone, using my initial example, write a chunk of code like so: ----- c.d ----- import a; B var; int main() { var.x = new A(); var.x.x = new B(); var.x.x.x = new A(); } on into infinityYes, because they're classes. If they were struct, it would be a circular field error.
Mar 18 2003
"Burton Radons" <loth users.sourceforge.net> wrote in message news:b59753$263r$1 digitaldaemon.com...Deja Augustine wrote:canYeah, that's not really what I was asking. What I wanted to know was,Okay. As a side note treat for anyone reading this, I hope to have DEnv Beta 1.2f out sometime this week.someone, using my initial example, write a chunk of code like so: ----- c.d ----- import a; B var; int main() { var.x = new A(); var.x.x = new B(); var.x.x.x = new A(); } on into infinityYes, because they're classes. If they were struct, it would be a circular field error.
Mar 18 2003