Thread overview | ||||||
---|---|---|---|---|---|---|
|
April 30, 2010 newbie: Circular references across modules | ||||
---|---|---|---|---|
| ||||
This code describes the concept: module a; import B; struct A { B *ptr; } --------------------- module b; import A; struct B { A *ptr; } ----------------------------- Can this be done? Do both classes have to be in the same module? |
April 30, 2010 Re: newbie: Circular references across modules | ||||
---|---|---|---|---|
| ||||
Posted in reply to Larry Luther | On 04/29/2010 09:04 PM, Larry Luther wrote: > This code describes the concept: > > module a; > import B; > > struct A { B *ptr; } > > --------------------- > > module b; > import A; > > struct B { A *ptr; } > > ----------------------------- > > Can this be done? sure > Do both classes have to be in the same module? It's probably not a bad idea to put A and B in the same module, but you shouldn't run into any trouble as you are, as long as you don't need any static constructors or destructors in either a or b. |
April 30, 2010 Re: newbie: Circular references across modules | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ellery Newcomer | Hello Ellery, > as long as you don't > need any static constructors or destructors in either a or b. It's a side issue but: static constructors + cyclic imports == pain -- ... <IXOYE>< |
April 30, 2010 Re: newbie: Circular references across modules | ||||
---|---|---|---|---|
| ||||
Posted in reply to Larry Luther | Thanks for your help. |
Copyright © 1999-2021 by the D Language Foundation