Only the namespace-definitions under the purview of M.
This is the intent, and I believe what is currently expressed in the spec.
Hmm, wouldn’t this require translating all module units “at once” somehow? I would expect that for module interface partitions, but not necessary any module unit of the same module.
My worry here is that it is heavy handed, given that namespaces span translation units (beyond module boundaries) already.
-- Gaby
--
You received this message because you are subscribed to the Google Groups "SG2 - Modules" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
modules+u...@isocpp.org.
To post to this group, send email to mod...@isocpp.org.
Visit this group at
https://groups.google.com/a/isocpp.org/group/modules/.
- Are all the namespaces from some_library.h supposed to be visible in the module user? Or is that rule only supposed to apply to namespaces under the purview of the module? It seems unfortunate to pollute the scope of a module user with namespace names from implementation details of the module interface -- this seems like the kind of accidental name leakage that modules should protect us from.
Only the namespace-definitions under the purview of M.
- we could say that a namespace declared in a module interface unit is exported if either (a) it is declared with 'export' or (b) it contains any exported declarations,
This is the intent, and I believe what is currently expressed in the spec.
- and such a namespace is visible to other translation units in the same module if any declaration of that namespace occurs after the module-declaration.
Hmm, wouldn’t this require translating all module units “at once” somehow? I would expect that for module interface partitions, but not necessary any module unit of the same module.
- Alternatively, we could disallow exported declarations inside non-exported namespaces, and not make 'export' apply transitively to the contents of a namespace
My worry here is that it is heavy handed, given that namespaces span translation units (beyond module boundaries) already.
That is correct.
An export declaration is well-formed only in the purview of a module, so that covers against any other misinterpretation.
But I can see how the bits about a namespace with external linkage can be read/understood to be mean something different, and your clarifying amendment
sounds like a good starting point. I will add to the module issue list.
namespace A {
int n;
}
// separate TU
import M;
// is ::A declared here?
namespace B = A; // valid?
Actually, that is well-formed (and the design calls for it to be well-formed), precisely thanks to the bits about a namespace with external linkage being exported regardless of whether it was lexically declared with ‘export’.
I believe this is necessary because of the fact that namespaces globally span translation units beyond module boundaries.
If we see a need for control of visibility restricted to module boundary, we should have lexical construct for that. For example, at the Lenexa meeting, I suggested we make lexical room for things that should be ‘module internal’, e.g. ‘internal’ specifier or something to that effect.
OK, great!
Good. That follows the model as explained above.
- But I suppose the name lookup rule in [basic.scope.namespace]p1 actually only makes visible names that are in the purview of a module.
That is correct.
An export declaration is well-formed only in the purview of a module, so that covers against any other misinterpretation.
But I can see how the bits about a namespace with external linkage can be read/understood to be mean something different, and your clarifying amendment
- "A namespace with external linkage <ins>declared within the purview of a module</ins> is always exported [...]".
sounds like a good starting point. I will add to the module issue list.
- module M; // [[interface]] or whatever other syntax is chosen
namespace A {
int n;
}
// separate TU
import M;
// is ::A declared here?
namespace B = A; // valid?
Actually, that is well-formed (and the design calls for it to be well-formed), precisely thanks to the bits about a namespace with external linkage being exported regardless of whether it was lexically declared with ‘export’.
I believe this is necessary because of the fact that namespaces globally span translation units beyond module boundaries.