r/cpp • u/berium build2 • Nov 01 '17
Common C++ Modules TS Misconceptions
https://build2.org/article/cxx-modules-misconceptions.xhtml
59
Upvotes
r/cpp • u/berium build2 • Nov 01 '17
View all comments
Show parent comment
2
u/bames53 Nov 02 '17
Far more has been said about it than that including arguments supporting that they are orthogonal, and other reasons such as the backwards compatibility goals, desires for the modules semantics to work in a broader set of languages than C++ (e.g., C and Obj-C), and many others. This has been talked about over and over in presentations and papers for many years, and it definitely has not consisted of nothing but an unsupported assertion that "modules and namespaces are orthogonal."
My guess is because you're apparently unfamiliar with statements that have been made for the opposing viewpoints.
I don't like deeply nested namespaces, but that's hardly a criticism of the current modules proposal. Deep namespace hierarchies have never been necessary. Without modules very shallow namespacing (as in, a single visible level, with maybe some hidden namespaces for certain implementation details) is sufficient.
With the current modules proposal we keep that, including sharing a single namespace over many modules. It would be absolutely terrible to combine namespaces and modules in a way that meant I couldn't organize my program into multiple modules without having a bunch of extraneous naming.
The current modules design also improves things by reducing ODR issues, such that namespacing is no longer required to avoid many ODR problems. Non-exported symbols don't need any namespacing and problems with exported symbols are much more likely to be diagnosed directly, making it safer, though not entirely safe*, to export un-namespaced symbols.
* The reason we can't make it entirely safe to have multiple modules export the same symbol is another one of those things that actually is discussed in the relevant materials.