December 29, 2019 Stupid global variable syntax question... | ||||
---|---|---|---|---|
| ||||
Is it considered poor programming practice to have two modules import each other? I've got lots of global variables (i know bad programming) in the module with main() module app; import game; // __gshared stores the variable in the classic global data segment. __gshared enum bool particulate = true; module game; import app; // needed or else get undefined identifier particulate if (particulate) { ... Is there a better way to structure this? |
December 29, 2019 Re: Stupid global variable syntax question... | ||||
---|---|---|---|---|
| ||||
Posted in reply to WhatMe Worry | On Sunday, 29 December 2019 at 03:45:03 UTC, WhatMe Worry wrote:
> Is it considered poor programming practice to have two modules import each other?
>
> I've got lots of global variables (i know bad programming) in the module with main()
>
>
>
> module app;
>
> import game;
>
> // __gshared stores the variable in the classic global data segment.
>
> __gshared enum bool particulate = true;
>
>
>
>
>
> module game;
>
> import app; // needed or else get undefined identifier particulate
> if (particulate)
> {
> ...
>
>
> Is there a better way to structure this?
You can split out the parts that both modules need into a third module, and have both of them import that instead of importing each other.
|
Copyright © 1999-2021 by the D Language Foundation