5 ms·
I think the funniest part is that you have to add ‘module;’ at the start, as if the extension doesn’t make that clear, or that the file exports the module expli
by evrimoztamur 3y ago
I think the funniest part is that you have to add ‘module;’ at the start, as if the extension doesn’t make that clear, or that the file exports the module explicitly with ‘export module mod1;’
You guys OK in C++ land?
- dagmx 3y agoC++ file extensions aren’t standardized unlike other languages. Hence the need for keywords to enable functionality. So you can’t really rely on extensions to be sufficient. Many build systems and compilers do assume specific extensions imply a file type by default, but those can often be configured to arbitrary extensions as well.
- IshKebab 3y agoExisting C++ file extensions aren't standardised. There's no reason they couldn't mandate file extensions for this. And really even among the non-standard extensions it's like 95% .cpp, 4.9% .cc and 0.1% .c++. Ignoring the weirdos it's de facto .cpp or .cc. They could standardise that too if they really wanted and there was a benefit. This sounds like one of those things that often happens where people worry about technically possible but totally insignificant risks, and insist on handling them because they feel proud of having thought of them. Not enough YAGNI.
- Conscat 3y agoWhat .ii for preprocessed files? And .ipp and .tpp for template implementation files?
- groos 3y agoYou forgot .cxx
- dagmx 3y agoYou’re missing cxx and mm, which are more common in codebases I deal with than most of your examples. Which is to say you can’t make sweeping statements. Anyway, I’d try and contextualize your argument more by adding that feature teams are restricted in the scope of the changes they can do to the features they’re working on. They can certainly suggest that the language specify specific extensions but that goes against decades of convention, and is a hill that would likely have taken more of their time and energy for little specific gain for the feature itself. I’m not arguing that there shouldn’t be standard extensions, just that I can understand why it didn’t happen. It’s like swimming upstream
- IshKebab 3y agoAh yes `.cxx` is rare but used. I haven't seem `.mm` for decades. IIRC gtkmm uses that? No maybe not, they use `.cc`. What on earth uses `.mm` now? Anyway none of that really changes the point - they could easily standardise extensions. The only reason they haven't is because there has been no real benefit until now.
- dagmx 3y agocxx is what msvc prefers hence why they picked icxx for their module types. mm is convention for ObjC++ files, which is a required dialect if you need to use most the platform libs on Apple platforms. Being the standard extensions for the two most major platforms, I wouldn’t call them rare at all. And which further reinforces my point. They could have mandated an extension BUT it would have been going against convention which makes it decidedly not easy. There’s not one singular team in charge and there’s lots of friction in such a seemingly minor change. I’d argue too that even with modules there’s very minimal benefit to a standard extension. Any such benefit would have had even greater benefit for the rest of the language.
- mathstuf 3y agoThe implementations have no agreement here. Clang "likes" `.cppm` while MSVC "likes" `.ixx`. I don't think there's any hope for agreement on extensions.
- humanrebar 3y agoPart of the justification is the lack of optimism that file extensions could be mandated (I'm less pessimistic). But it's also an important hint to the preprocessor to make pre-build dependency scanning faster. You don't want to have to compile all possible source files and then throw a bunch of that work away once you find there are module dependencies in the source files. Just having a magic file extension is not enough to clarify that. A C++ packaging standard could help there, but C++ started with modules, probably because they seemed simpler.
- bluGill 3y agoThere should not be a c++ standard for packages. Maybe an ISO standard, but it needs to work for all languages, otherwise we will all roll our own. If the package can't support all languages it doesn't support the complex world C++ is used in.
- humanrebar 3y agoThere is some work in that direction but no specific ISO proposals yet.
- bluGill 3y agoIt is a very hard problem. I'd be concerned if there was a proposal.
- mathstuf 3y agoThat is only if you have a global module fragment. Without that, you can start right off with `export module M;`.