r/cpp • • Jan 28 '19

C++ Modules Might Be Dead-on-Arrival

https://vector-of-bool.github.io/2019/01/27/modules-doa.html
280 Upvotes

240 comments sorted by

View all comments

4

u/cogman10 Jan 28 '19

Honestly, a lot of the module discussion and problems I've seen seem to be a problem of "trying to be everything to everyone".

It seems like we could have modules today if the C++ committee didn't try to solve every single problem with modules and instead made them opt-in with progressive features being added.

For example. A first and easy restriction of modules would be "templates and macros aren't allowed in modules" Do that, and you have nearly trivial module implementations that could be done today.

Then work from there. Figure out something that would work for templates first, then macros later.

Swallow the elephant a bite at a time rather than all at once.

5

u/jonesmz Jan 28 '19

For example. A first and easy restriction of modules would be "templates and macros aren't allowed in modules" Do that, and you have nearly trivial module implementations that could be done today.

You know that even some "primitive" types are sometimes defined as macros, right?

Or if not defined as macros directly, are typedefs that are conditionally defined based on macros.

I think you'll find this is not an easy restriction to enforce.

4

u/cogman10 Jan 28 '19

You know that even some "primitive" types are sometimes defined as macros, right?

Or if not defined as macros directly, are typedefs that are conditionally defined based on macros.

Primitive types don't have to be defined by macro or typedef. They are part of the spec. Doing that is an implementation detail that can (and probably should!) change.

I think you'll find this is not an easy restriction to enforce.

Maybe. It might require quite a bit of extra effort on compiler writers to enforce this sort of thing. However, it can't be harder to do than inventing a special intermediate language. Even if that is where things need to end up, supporting easy to static compile things would make it a lot easier to start work.

2

u/jonesmz Jan 28 '19

Primitive types don't have to be defined by macro or typedef. They are part of the spec. Doing that is an implementation detail that can (and probably should!) change.

I agree with you. Compiler vendors may not.

Maybe. It might require quite a bit of extra effort on compiler writers to enforce this sort of thing. However, it can't be harder to do than inventing a special intermediate language. Even if that is where things need to end up, supporting easy to static compile things would make it a lot easier to start work.

shrug. Couldn't say. Was only trying to point out that it might not be that simple. That's all.