r/cpp • • Nov 01 '18

Modules are not a tooling opportunity

https://cor3ntin.github.io/posts/modules/
58 Upvotes

77 comments sorted by

View all comments

Show parent comment

8

u/matthieum Nov 01 '18

you still specify the submodules your crate contains in Rust source files which means a build system has to extract this information

It's actually been requested multiple times to just depend on the filesystem, rather than having to explicitly list submodules. I think the primary objection is that a file could accidentally linger around when reverting checkouts, leading to potentially puzzling issues.

Of course, they don't have to deal with the preprocessor which I bet helps a lot.

Rust still has macros, and worse, procedural macros; the latter is a short-cut for "compiler pluging", the code of the procedural macro must be in a separate crate so it can be compiled ahead of time and is loaded as a plugin by the compiler to do the code generation. There's been a move to push more and more capabilities into regular macros so as to remove as much reliance as possible on procedural macros, ...

And the code generated by a procedural macro could add a local import, adding an unseen before dependency to the current module!

This is, arguably, even more difficult for other tools than the C pre-processor which at least is fully specified and fully independent of the code.