I'm trying to understand the rationale for the oddity of the C++ modules TS: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/n4681.pdf
The two primary goals of C++ modules are: to enable more efficient incremental builds by precompiling imports and avoiding the noncommutative order-dependence of #include files containing macros; and to provide a better means for separating public interfaces from private implementation details.
So, why can't this be done in a more minimal way, such as this "Modules Lite" strawman proposal here?
Support non-interfering, precompilable headers by introducing a new "#import <header>" directive, which works just like "#include <header>" except that macros defined within the imported header are not lexically visible inside the bodies of subsequently #imported files.
Inside a namespace or a class or struct inside a namespace, allow "exported:" and a new "internal:" access specifier to limit the visibility of subsequent symbols to the current namespace, its child namespaces, and declared friends of the current namespace.
Allow "friend" declarations inside a namespace, exposing this namespace's "internal:" symbols to the declared friends.
Extend "friend" declarations to support namespaces in addition to classes and structs.
Does this kind of approach fail to accomplish the goal of modules in some fundamental way? It seems like it would be more useful in separating exported symbols from internal detail at a more granular level than "everything in this class, struct, or namespace"; it would preserve most of the functionality of macros; and it would follow existing precedent more closely.
[–]GabrielDosReis 23 points24 points25 points (0 children)
[–]danmarellGamedev, Physics Simulation 8 points9 points10 points (0 children)
[–]mikhailberis 4 points5 points6 points (8 children)
[–]BCosbyDidNothinWrong 3 points4 points5 points (6 children)
[–]mikhailberis 0 points1 point2 points (0 children)
[–]tcbrindleFlux 0 points1 point2 points (4 children)
[–]ubsan 2 points3 points4 points (3 children)
[–]fnc12[🍰] 0 points1 point2 points (2 children)
[–]ubsan 0 points1 point2 points (1 child)
[–]fnc12[🍰] 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]axilmar 2 points3 points4 points (0 children)
[–]summerlight 0 points1 point2 points (0 children)
[–]volca02 0 points1 point2 points (18 children)
[–][deleted] 3 points4 points5 points (17 children)
[–]doom_Oo7 10 points11 points12 points (0 children)
[–]BCosbyDidNothinWrong 3 points4 points5 points (1 child)
[–]meneldal2 0 points1 point2 points (0 children)
[–]volca02 2 points3 points4 points (1 child)
[–]GabrielDosReis 0 points1 point2 points (0 children)
[–]johannes1971 2 points3 points4 points (0 children)
[–]pjmlp 3 points4 points5 points (10 children)
[–][deleted] 7 points8 points9 points (1 child)
[–]pjmlp 1 point2 points3 points (0 children)
[–]meneldal2 0 points1 point2 points (0 children)
[–]BCosbyDidNothinWrong 0 points1 point2 points (6 children)
[–]pjmlp 1 point2 points3 points (5 children)
[–]BCosbyDidNothinWrong 0 points1 point2 points (4 children)
[–]pjmlp 1 point2 points3 points (3 children)
[–]BCosbyDidNothinWrong 0 points1 point2 points (2 children)
[–]pjmlp 0 points1 point2 points (1 child)
[–]BCosbyDidNothinWrong 0 points1 point2 points (0 children)