2 ms·
The short story is that a "module" should be approximately the same thing as a "compilation unit". (Not a compilation unit, plus some fragmented-off textual hea
by kazinator 12y ago
The short story is that a "module" should be approximately the same thing as a "compilation unit". (Not a compilation unit, plus some fragmented-off textual header file.). Secondly, information about the public interface of that compilation unit must somehow be marked off, and provided for the compilation of dependent modules.
A more digestible description of this can be found in a Modula 2 reference manual:
http://www.modula2.org/reference/modules.php http://www.modula2.org/reference/modules.php
The Modula 2 compiler I worked with years ago simply had you put the definition modules into .def files and the implementation modules into .mod files. So it's vaguely like headers, except that the .def files have structure and can be compiled; the compiled info is then referenced during compilation of the client modules. The .def file is never directly referenced as text.
- coliveira 12y agoTurbo Pascal used a similar scheme, but they split every source file into an "interface" and an "implementation" section. The interface would end up as information exported to other modules, but in binary form. No other part of the process had to read the original source file.
- _pmf_ 12y agoIt's similar in Ada.
- pjmlp 12y agoModules go at least all the back to Algol 68 and Mesa, but C designers choose to ignore them. C++ design goal of being able to target unmodified C toolchains as a means of being accepted by C developers, meant C++ also had to keep away from modules. Luckily C++ can stand on its own nowadays and depart from such decisions.