C++ Logo

sg15

Advanced search

Re: Questions about wording and design intention for header units and ideas

From: Tom Honermann <tom_at_[hidden]>
Date: Tue, 23 May 2023 21:39:44 -0400
On 5/23/23 8:30 PM, Daniel Ruoso wrote:
> On Tue, May 23, 2023, 20:22 许传奇(夜灯) via SG15 <sg15_at_[hidden]>
> wrote:
>
> Now we can't assume `user.cpp` isn't the same with
> `user.orig.cpp`. It is surprising since such patterns are
> pretty common in practice. And I'm worrying that we'll meet
> problems if this is true.
>
>
> It's actually worse than that. Since the compiler is free to replace
> `#include` by the equivalent `import` the semantic change can happen
> even without any source change in the code.
>
> If someone declare the header to be importable, the semantics change
> silently.
>
> As I said before, so far, early experiences simply put the burden on
> the user not to choose headers where this would be a problem.

Yes. That is my understanding of the intent. If a header file is not
sufficiently "modular", then it should not be nominated as importable
and therefore should not be considered eligible by the implementation
for #include-translation.

I don't recall when you started participating in WG21. In case you
haven't read it, I think P0947 (Another take on Modules)
<https://wg21.link/p0947> is helpful for understanding the intent and
rationale for much of the design that is in the standard.

Tom.

>
> Daniel

Received on 2023-05-24 01:39:46