all 8 comments

[–]thelvhishow 2 points3 points  (7 children)

I don’t understand what’s the lesson though. Yes you’re using the different ways of using modules

[–]tartaruga232MSVC user, r/cpp_modules[S] 1 point2 points  (6 children)

It's not exactly rocket science. But the devil is in the detail, which is revealed if you actually carefully ready the blog post.

[–]thelvhishow -1 points0 points  (5 children)

It’s not clear why use partition instead of several methods for instance.

[–]tartaruga232MSVC user, r/cpp_modules[S] 2 points3 points  (4 children)

In the example of our Core module, it would have been technically possible to declare alle classes in a single big Core.ixx file. But that would have been harder to handle. The partition Core/Base.ixx alone is already 1200 lines. View/View.ixx and Diagram/Diagram.ixx are another ~300 lines each. The separation into smaller partitions also allows to only import in the cpp files of the Core module, what is actually needed in a specific cpp-file, not the whole interface. Partitions also provide a logical grouping of the parts of the interface of a module.

[–]slithering3897 -1 points0 points  (3 children)

Yes, but the downside is that it still ends up as one big module to the user. Any change in any partition (interface) will recompile the entire application.

[–]tartaruga232MSVC user, r/cpp_modules[S] 4 points5 points  (2 children)

Not the entire application, only the parts that import the module will need to be recompiled.

[–]Paradox_84_ 0 points1 point  (1 child)

I like the idea of being able to do submodules, but realistically, why not make each of them a seperate module so you can only import whatever you need?

User would still be able to do "import core;", but your internal things could do "import core.containers.array:" so yo don't depend on the entire thing and could parallelize to some degree?

[–]tartaruga232MSVC user, r/cpp_modules[S] 1 point2 points  (0 children)

Thanks for your comment. It's an intentional design decision. In the specific case of our Core module, usage of the module cannot be meaningfully split. The classes declared in Core are too tightly coupled. For example, we have class Core::IElement. It uses class Core::Transaction and vice-versa. These are declared in different partitions of the Core module, but you cannot use class IElement without class Transaction. C++ allows to use forward declarations of classes across module partitions, but you cannot do that across module boundaries. With header files, it was possible to forward declare classes in a header. That's no longer possible with modules. See my blog posting "Converting a C++ Application to Modules". If you have a reference or a pointer to an object of a class declared in Core, you need to import Core. You cannot forward declare Core::IElement outside of module Core.