Here’s the thing I don’t get about module partitions: They only seem to allow one level of encapsulation.
Program
- Module
- Module Partition
whereas in module systems that support module visibility, like Rust’s, you can decompose your program at multiple abstraction levels: Program
- Private Module
- Private Module
- Private Module
- Public Module
- Public Module
Maybe I am missing something. It seems like you will have to rely on discipline and documentation to enforce clean code layering in C++.Like most languages with modules.
Rust, Modula-2 and Ada are probably the only ones with module nesting.
I don't think you're missing something. The standards committee made a bad call with "no submodules", ran into insurmountable problems, and doubled down on the bad call via partitions.
"Just one more level bro, I swear. One more".
I fully expect to sooner or later see a retcon on why really, two is the right number.
Yeah, I'm salty about this. "Submodules encourage dependency messes" is just trying to fix substandard engineering across many teams via enforcement of somewhat arbitrary rules. That has never worked in the history of programming. "The determined Real Programmer can write FORTRAN programs in any language" is still true.
Rust's re-exports also allow you to design your public module structure separate from your internal structure.