2 ms·
I haven't read much at all about this, but why couldn't modules work like this? Header, source like before. Allow putting all implementations in the source (in
by im3w1l 8y ago
I haven't read much at all about this, but why couldn't modules work like this?
Header, source like before. Allow putting all implementations in the source (including templates). Allow private member functions to be defined in the source file even though they were not declared in the class. Every function that is not declared in the header is no-external-linkage (including these adhoc private members). Defines don't leak into header file from including files unless explicitly passed into it (using some new syntax). Defines can leak out of header files. If the define already exists it's an error (the point of this is to make sure that order doesn't matter), unless the origin of the define is the same (so if x includes y and z, and y includes z, then a define in z would go into x directly and also through y which would not be an error).
This seems like it should be a strict improvement.
- creato 8y ago> Header, source like before. Allow putting all implementations in the source (including templates). Do you realize how hard this is to implement? This actually was part of the original C++ spec (export keyword), but no compiler successfully implemented it in a way that was compatible with other compilers, and it was deprecated. This (and C++ modules) requires a standard intermediate representation of the language that all compilers share, otherwise compiler A can't use a module generated by compiler B. This is why I've never really expected C++ modules to ever exist, or if they do, it will be in a form that is much more limited than most people want or expect. Either they'll only allow a subset of the language to exist in a module, or the feature won't be much different than the "pre-compiled header" feature offered by most C++ compilers), or modules won't be portable across compilers (and maybe even versions of the same compiler).
- bigcheesegs 8y agoThis has always been a problem in talking about modules in C++. Everyone has a different idea of what a module is. Currently every compiler except MSVC plans to make module files version locked. Different versions of the same compiler will use different module files. Personally I find little value in portable module files, as you need to be able to rebuild modules anyway to handle pretty much any change to compile flags.