I have several modules that each have some object types defined (some objects and ref objects), they need for some reason to have some sort of inter-dependence. To break the circularity of the types i have initially added some global tables where i store objects to be tracked (so i don't have to inject these objects into the parent one, so the parent defines the children and the children have to know about the parent, ending up with circular imports), or i use pointer in the parent to refer to the child (if the child needs to know about the parent) and use casts. I don't know what i like most, probably neither of these...
I started refactoring the thing, and i ended up moving ALL the type sections in my whole project into a "master" types.nim to be able to progress... what is the idiomatic way to have forward declarations for types in different modules so i don't end up with a gigantic "all my types are here" .nim or with global tables hacks and pointers ? For functions i was able to make it work by exploiting {.exportc.} and {.importc.} in another module, but it's far from great either.
I think this is the only thing at this moment that is creating a bit of friction on the development... Hope you guys can enlighten me!
One master module for most types named "types.nim" is pretty idiomatic.
You can see some alternative solutions in this RFC.
Also, solution for cyclic module dependencies is planned for Nim 3. From the 2025 Roadmap "Version 3" section:
Allow for explicit cyclic module dependencies.