r/cpp_modules • u/slithering3897 • Mar 31 '26
Should partitions be importable by other modules?
Because, there are two things that are nice to have:
- Forward declarations across interfaces.
- Minimising dependencies.
Partitions gets you (1), multiple modules gets you (2). But they can't be combined without using the extern "C++" sledgehammer.
But if partitions could be "public", an application can avoid depending on a whole module.
This could also be seen as "packages". You could get the same functionality by changing "module attachment" to "package attachment": use the same symbol mangling for a group of modules.
Then what's left is forward declarations of things from external "packages". And for that, you'd have that "proclaimed ownership" proposal.
3
u/TheRavagerSw Mar 31 '26
No, you should create another interface module for such things.
2
u/tartaruga232 Mar 31 '26
Thanks a lot for your first posting to r/cpp_modules!
I probably haven't yet thought deeply enough about your idea, but it I feel this would be a rather larger change to what the current C++ standard says...
If I have a partition
A:foolike this:I can use that in a different partition of A:
Inside
A:barthen both typesS1andS2are available. Note thatS2is available inA:bar, even though it is not exported.So far, nothing new.
When I would import
A:fooin module B, what should happen? IsS2available or not? If it is not available, isA:foomeaningfully usable by just importingA:foo?2
u/gracicot Apr 02 '26
The things that brought me to use partitions at all is the fact that their name and the amount of them don't affect API (visible module names) and ABI (mangling). I don't understand what externally visible partition would bring that dot separated module names can't do.