Comment

Comment by WalterBright

Back in the 90s, I implemented precompiled headers for my C++ compiler (Symantec C++). They were very much like modules. There were two modes of operation:

1. all the .h files were compiled, and emitted as a binary that could be rolled in all at once

2. each .h file created its own precompiled header. Sounds like modules, right?

Anyhow, I learned a lot, mostly that without semantic improvements to C++, while it made compilation much faster, it was too sensitive to breakage.

This experience was rolled into the design of D modules, which work like a champ. They were everything I wanted modules to be. In particular,

The semantic meaning of the module is completely independent of wherever it is imported from.

Anyhow, C++ is welcome to adopt the D design of modules. C++ would get modules that have 25 years of use, and are very satisfying.

Yes, I do understand that the C preprocessor macros are a problem. My recommendation is, find language solutions to replace the preprocessor. C++ is most of the way there, just finish the job and relegate the preprocessor to the dustbin.

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton