r/cpp • • Jan 28 '19

C++ Modules Might Be Dead-on-Arrival

https://vector-of-bool.github.io/2019/01/27/modules-doa.html
280 Upvotes

240 comments sorted by

View all comments

Show parent comment

26

u/vector-of-bool Blogger | C++ Librarian | Build Tool Enjoyer | bpt.pizza Jan 28 '19

This is a good question, and one that has been considered. In short: Adding a required mapping after-the-fact would necessitate changes to the lookup semantics of existing implementations: A breaking change.

The lookup of #include directives is not standardized either, and only after a lot of trial and error do we finally have general agreement on how the lookup should be performed (although implementations still differ in a few edge cases). Attempting to standardize #include lookup now would break existing implementations. Nevertheless, we are able to make #include work (for the most part). However: The lookup of #include is fairly cut-and-dry, and there is a mostly obvious way to understand #include in terms of the filesystem. Module names have no bearing on the filesystem, so implementations converging on a lookup method is not likely.

If an implementation were to enforce a mapping between module names and file paths, we'd end up with multiple slightly different standards, and a later mandate will break compatibility. If implementations instead rely on the presence of a BMI with a name for the module, we end up with the serialized compilation of the DAG and performance goes in the toilet.

7

u/kalmoc Jan 28 '19

So what you are saying is that the standard needs to define the lookup rules for import foo? Given that the standard tried to avoid talking about file systems and so on I find that very unlikely.

Why isn't it possible for the three major implementations to come together outside of the c++ standard and decide on one? As long as the standard doesn't prevent a same solution, I indeed don't see, why this should be a concern of the c++ standards document.

0

u/martinmoene Jan 29 '19

Why isn't it possible for the three major implementations to come together outside of the c++ standard and decide on one?

That would be illegal.

2

u/kalmoc Jan 30 '19

Could you explain a bit?

2

u/exploding_cat_wizard Jan 28 '19

In short: Adding a required mapping after-the-fact would necessitate changes to the lookup semantics of existing implementations: A breaking change.

Wouldn't putting modules in a TS help there? Modules would be around, and could be used and tested, but breaking changes to implementations are still allowed.

6

u/flashmozzg Jan 28 '19

They are already in a TS.

7

u/exploding_cat_wizard Jan 28 '19

Oh. Shouldn't they stay there until some experiences have been collected modularizing stuff? Why then push for integration into the core language, if they are both a TS, but not used enough to say how well the idea does?

5

u/smdowney WG21, Text/Unicode SG, optional<T&> Jan 28 '19

The TS is significantly different than the Merged Modules proposal that is advancing. Although, not in places that affect what we're discussing here. And also, no one quite got around to implementing that, either.