3 ms·
Nice post! When playing with modules, I noticed a major caveat that makes me dislike them very much: the standard says that modules must form acyclic graphs. T
by gmueckl 5y ago
Nice post!
When playing with modules, I noticed a major caveat that makes me dislike them very much: the standard says that modules must form acyclic graphs. This means you still cannot get rid of forward declarations and you must put interfaces and implementations into different files for any realistically sized code base. So, in terms of effort, you still have to maintain the equivalemt of headers, just with a different name and less preprocessor macro interference.
- hoseja 5y agoOh that's unfortunate.
- gmueckl 5y agoUnfortunate, yes. But it keeps with the spirit of a language that is designed for both single pass compilation and separate compilation. A module system that mimics other languages like D or Python (I don't know enough about rust) would require a major change to how C++ compilations works. The compilers are by now complex enough that I'm pretty sure that compiler developers aren't keen on rewriting their frontends for multi-pass compilation.
- creata 5y ago> I don't know enough about rust Rust allows cyclic dependencies between modules within a single crate, but not between crates.
- pjmlp 5y agoThat is true of most module systems anyway, and it was already an huge battle to get them adopted at all.
- gmueckl 5y agoWhich module systems are you thinking of? The only ones that I think come close are the ones in Pascal and its successors.
- pjmlp 5y agoMesa, Mesa/Cedar, Modula-2, Modula-3, CLU, Eiffel, Ada, Oberon, Oberon-2, Oberon-07, Component Pascal, Active Oberon, COM/WinRT, .NET. Probably there are others as well.
- gmueckl 5y agoWhat makes you include .NET? C# and VB.net handle cyclical dependencies between classes / source files just fine. Partial classes are the most extreme example of that. Assemblies are different, but so are static/dynamic libraries.
- pjmlp 5y agoAssemblies are what maps to modules in concept, specially given polyglot projects. If you want to stay in one language, then F# imposes compilation order, even Visual Studio has support to rearrange file order on the project file.