Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

What's your definition of a "module" that is not a class, not an object file, not a .so, and not a namespace?

I'm not trying to be argumentative. I've seen this "C++ doesn't have modules" claim before, and I'm trying to get my mind around it.



Part of the reason that "modules" aren't in C++ yet is that there isn't a precise definition of what modules are or what they should be.

That being said, C++ doesn't have even the bare minimum of what would be considered a module system according to any definition. With a lot of hand waving, one should be able to more or less write:

    import std::vector;
...and have the compiler (not the preprocessor!) find the relevant declarations and definitions for std::vector. Probably also important are additional restrictions to give more control over when and how preprocessor macros affect client code.


C++ does not have modules. When people say modules they mean how the files compile, and the current way is #include directives which literally copy-pastes the contents of that file into the includer file. This is horribly horrible for compile times, and has been reviled for basically ever.

Here read this:

http://clang.llvm.org/docs/Modules.html


Right now the way you use a module in C++ is to tell the compiler to dump a subset of its source-code from that module into each file that uses it. Then you tell the linker to link in the objects from that module later.

This is a pretty ridiculous and highly inefficient way of doing things (Facebook improved compile times by crafting a server just to do the preprocessing for you).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: