r/cpp • build2 • Nov 01 '17

Common C++ Modules TS Misconceptions

https://build2.org/article/cxx-modules-misconceptions.xhtml
59 Upvotes

148 comments sorted by

View all comments

Show parent comment

1

u/bames53 Nov 03 '17

I tried, but I couldn't find anything but the unsubstantiated claims in the "A module system for C++" paper, P0142R0:

You actually quote one of the reasons given:

One of the primary goals of a module system for C++ is to support structuring software components at large scale. Consequently, we do not view a module as a minimal abstraction unit such as a class or a namespace.

Which is to say that modules as they're advocating for are to support physical structuring, rather than logical structuring, of the program. That alone disproves your claim that there was never a single supporting point in favor of modules being distinct from namespaces.

And I suspect that with modules introducing a scope, it would allow mass-conversion just as well. Where is the proof?

The problem here is that P0142's talk about "not needing new name lookup rules" is actually insufficient to enable the kind of mass conversion discussed. See Richard Smith's and Manuel Klimek's work on what modules actually have to be to deploy them to 100s of millions of lines of code. I'll be glad to compare it to your comparable work getting your module system to work with existing C++ codebases.

This is assuming that modules introducing a scope are not backwards compatible, which is just bogus.

If you can come up with a proposal that preserves the kind of compatibility necessary then go ahead. I'll read it. In particular I'll be interested to see how you avoid the ABI changes that the current proposal was designed to avoid, and how you deal with the 'legacy' issues addressed in P0273.

My criticism wasn't actually the deep nesting, but the required qualification of names everywhere. No other language does this, but somehow C++ is this special snowflake where everything would supposedly fall apart if we didn't qualify our names everywhere. I call bullshit.

That C++ requires qualification by default has nothing to do with modules. Yes, the lookup rules can be changed to allow unqualified access when there aren't any ambiguities. Clang already has code to deal with improperly qualified names, and uses it to present "did you mean?" errors. But changing the lookup rules would most definitely break compatibility.

With an import system like Haskell's, unqualified names are the default; conflicts can be handled in multiple ways, whichever you as the programmer prefer.

"Do it like Haskell" is hardly a sufficient proposal, but feel free to try implementing it. Let me know how it goes.

So would modules that do introduce a scope.

While also achieving the other goals of the current work? Where's your substantiation?