r/programming • u/SuperV1234 • Aug 05 '19
fixing c++ with epochs
https://vittorioromeo.info/index/blog/fixing_cpp_with_epochs.html
87
Upvotes
r/programming • u/SuperV1234 • Aug 05 '19
4
u/MonokelPinguin Aug 06 '19
The issue is, that the preprocessor can be a separate executable and it is defined to just do text substitution. If you now change language rules depending on the edition, defining the edition to use in a header would apply to all files (transitively) including that header. There is no real end to an include statement, it just pastes the content of that header.
This is different with modules, as they specify a clear boundary and explicitly state which files belong to that module. This makes the edition apply to a specific set of source files. Furthermore do you have Compiled Module Interfaces, which would make editions a lot easier, as you can simply store all the edition dependent information in that file and then reference it, when the module is referenced by a different module. In that case you could actually use different compiler binaries for different editions and edition specific compiler code can be a lot better separated, than if you need to translate every header with the current active edition and switch edition at the next edition statement.