Open eggrobin opened 2 years ago
I think 9.2.8 7 is the only thing there which requires definition in the definition domain, as opposed to definition reachable from (the end of) the definition domain. This is weird.
One could have hoped that the _body could be relegated to a module partition. Unfortunately, a look at N4868 shows that we cannot put those definitions that we had to put in headers in separate files; see below.
Also, clang does not yet support module partitions.
10.1
7 A module is either a named module or the global module. A declaration is attached to a module as follows: (7.1) — If the declaration (7.1.1) — is a replaceable global allocation or deallocation function (17.6.3.2, 17.6.3.3), or (7.1.2) — is a namespace-definition with external linkage, or (7.1.3) — appears within a linkage-specification, it is attached to the global module. (7.2) — Otherwise, the declaration is attached to the module in whose purview it appears.
6.6
9 Two names that are the same (6.1) and that are declared in different scopes shall denote the same variable, function, type, template or namespace if (9.1) — both names have external or module linkage and are declared in declarations attached to the same module, or else both names have internal linkage and are declared in the same translation unit; and (9.2) — both names refer to members of the same namespace or to members, not by inheritance, of the same class; and (9.3) — when both names denote functions or function templates, the signatures (3.51, 3.53) are the same. If multiple declarations of the same name with external linkage would declare the same entity except that they are attached to different modules, the program is ill-formed; no diagnostic is required. 10 If a declaration would redeclare a reachable declaration attached to a different module, the program is ill-formed. […] As a consequence of these rules, all declarations of an entity are attached to the same module; the entity is said to be attached to that module.
I think this means that we cannot forward-declare things from another module.
https://stackoverflow.com/questions/67952223/c-modules-forward-declaring-entity-from-another-module seems to say as much.
This means that we cannot have inter-module friendships of templatized (and inline, constexpr, etc.) classes and functions.
We have now switched to C++20; we should investigate modules to see if we can improve compilation times, and to get rid of the
internal_file_name
namespaces designed to hide convenienceusing
s.Overall, our current
meow.hpp
+meow_body.hpp
(+meow.cpp
in some cases) should correspond to a modulemeow
.One could have hoped that the
_body
could be relegated to a module partition. Unfortunately, a look at N4868 shows that we cannot put those definitions that we had to put in headers in separate files; see below.This means we will still have to resort to textual inclusion for the _body.hpp.
Prerequisites, which we should deal with prior to starting the great cosmic modularization:
.ixx
files must be compiled, in order to stop the spread of the « cbrt.cpp in every project » mess, we will have to put them into shared items projects referenced by whatever needs them. #3323.principia.cats.meow
should be in namespaceprincipia::cats::meow
. This entails restructuring our current namespace structure. #3321.On the unusability of module partitions