cxx-modules-sandbox
cxx-modules-sandbox copied to clipboard
Don't use .mpp extension for non modules
Ideally you wouldn't use that extension at all because clang silently doesn't emit object files for it, requiring -x c++. But if you think that is important, at the very least it should only be done for actual modules. https://github.com/mathstuf/cxx-modules-sandbox/blob/master/link-use/use.mpp is particularly incorrect because currently main() isn't allowed to be defined inside of a module.
I'm partial to the "extensions don't matter too much" view because it's all C++ code and the build system can't trust any of it until it scans the code anyways. At that point, we know what kind it is and we can just add whatever flags are necessary to make it be accepted. Sure, assumptions about the code based on the extension are fine, but they shouldn't be pre-destined because of it. If someone really wants to put C++ code into a .js file, I'm not going to question their life choices :) .
I agree with your viewpoint at a high level. How about renaming everything to .cpp? Build systems should be able to handle that.
My issue was with simultaneously introducing a new extension to distinguish modular code from non modular (which I agree is of questionable utility), and also using the modular extension for non modular code. It feels contradictory.
It was needed for build2 support since it requires such an extension. FWIW, it started off as .cpp in the beginning :) .