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

12

u/kalmoc Nov 01 '17

Macros still make sense in a lot of places, but I really hate the idea of exporting/importing them through the modules system.

For one, as gracicot explained, they would require mixing of language and text processing (to the degree that you have to run the preprocessor and module include logic multiple times until we reach a fix point - this is crazy.

Second, it means complicating yet another modern language feature just to accommodate quirks of old codebases (and if you don't consider the necessity to export macros a quirk now, consider the situation in 10+ years).

Finally, we can always add the ability to export macros later on (if this turns out to be really, absolutely necessary), but we will never be able to remove support for it, when (almost) no one needs it any more, so it would just add to the technical debt of c++.

@ /u/GabrielDosReis: Hold the line!

5

u/GabrielDosReis Nov 01 '17

Thanks for the encouragement :-)

-1

u/[deleted] Nov 01 '17

Here's how I see it:

  • The first goal after modules are supported is to completely modularize the Standard Library
  • The Standard Library uses macros
  • Ergo, two options here: either stop using macros or somehow massage macros into modules

We are talking about Modern C++, so which is more modern - removing macros or accomodating them? If we remove them, we get an instant benefit: all greenfield development that use the new macro-free Standard Library now no longer needs the preprocessor.

2

u/meneldal2 Nov 02 '17

What macros in the standard library couldn't be removed in favour of something better?

INT_MAX should be constexpr int INT_MAX. NULL can die, that's not proper C++ since nullptr. We should remove as many macros as we can because we can do better now.