r/cpp_modules • u/tartaruga232 • Apr 05 '26
The current internal partition units are unneeded
Gaby just confirmed that an internal partition unit (form "A") like
module M:P;
struct MyType { ... };as specified by the current C++ standard, is semantically 100% equivalent to (form "B")
export module M:P;
struct MyType { ... };
// more stuff not exportedThe current wording in the C++ standard, which qualifies form "B" as "ill-formed, no diagnostic required", if :P is not imported in the primary module interface unit, makes no sense (Quote: "A required no-op helps nobody").
Which means: Form "B" is perfectly valid.
If form "B" is equivalent to form "A", it would be possible to exclusively use form "B", instead of form "A".
This means, the standard could remove form "A" and exclusively use form "B" instead.
Compilers could then apply the simple rule, that a BMI must only be produced for TU's having "export module".
View all comments
Show parent comment
1
u/not_a_novel_account Apr 06 '26 edited Apr 06 '26
Ok, then you're talking about a substantially different system than exists or was standardized and implemented for C++. The time to have that conversation was 9 or 10 years ago, during drafting of the reachability rules. Or even earlier, when clang modules were being implemented and the symbol visibility semantics were being worked out.
If you think the reachability semantics are pointless and should be discarded, the people to have that conversation with are the compiler implementers who advocated and implemented them. If you convinced them that the behavior of unreachable declarations and definitions should not be unspecified in the standard, but rather be standardized to have the same trivial semantics they have in MSVC, then there would be a smaller gap between your current proposal and the existing language.
I wouldn't hold your breath on that.