[fpc-devel] "Friend" classes?

DrDiettrich drdiettrich at compuserve.de
Tue Mar 22 10:00:26 CET 2005

Florian Klaempfl wrote:

> C++ creates one monster module in this case as well.

I disagree. Neither the declarations (interface, header files) nor the
definitions (implementation, code modules) must reside in one file. C
header files can #include each other, and some more or less advanced
techniques can prevent multiple inclusion of the same header file.

> You could do the
> same as in C++: split everything into include files. Pascal units aren't
> 1:1 equivalent of C++ include files, if C++ libraries are done properly,
> you can translate namespaces to pascal units.

Just a question about the compilation in C/C++ and Pascal. A C compiler
collects all required header files, prior to compiling a source module.
The recompilation of the header files for every single code file is one
reason for the slow C/C++ compilers. Namespaces IMO only have been
introduced to reduce the size of the symbol tables, resulting from the
many required header files.

In modern Pascal, as I see it, the compilation of every unit is done in
multiple steps, or passes, not in one pass as was possible with the
single-unit original Pascal. In the first pass the Interface sections
are compiled, of the unit itself and of all units in the Interface Uses
list. The resulting compiled Interface section now can be used in the
compilation of every other unit. In the second step the Implementation
part of the unit is compiled, including the Implementation Uses list.

Or how else can the Interface section of unit A use unit B, when the
Implementation section of unit B uses unit A?

Sure, compiler threads for every unit are a quasi-parallel solution, but
then the threads become blocked between the compilation of the interface
and implementation sections, effectively splitting the compilation
process into 2 distinct steps.


More information about the fpc-devel mailing list