Partitions and Submodules (WIP)
Comparison of Partitions and Submodules
Entities declared in a partition but not exported are only accessible within that partition and by its importers. Other module units, even within the same module, cannot access them unless they import the partition. Alternatively, a partition can be viewed as a subunit with its own module linkage.
| Feature | Module Partition | Submodules |
|---|---|---|
| Encapsulation | Hidden from external code but shared within the module | Hidden from external code but not naturally shared within the module |
| Code Reuse | Usable by multiple module units | Requires manual inclusion (e.g., via a header or explicit linkage) |
| Faster Compilation | Does not trigger module consumers’ recompilation | Changes may require recompiling all users |
| Better Organization | Keeps internals modular while maintaining cohesion | Can lead to scattered internal dependencies |
| Module Dependency Management | Naturally integrates with module build system | Requires careful header and linkage management |