[fpc-devel] "Friend" classes?

DrDiettrich drdiettrich at compuserve.de
Fri Mar 25 13:34:59 CET 2005


Micha Nelissen wrote:

> > Perhaps you missed that in C/C++ the preprocessor is typically (99.999%)
> > used to include header files, not source files. This is comparable to
> > Pascal "uses", not to {$Include}!
> 
> What's the difference between a 'header' file, and a source file ? Header > files often contain template classes with inline implemented methods.
> Preprocessor is used also for macros.

The definitions of templates, inline procedures or macros do not
immediately contribute to the size of a compiled module, only when they
are *used* in code modules.


> Please look again at 'uses', it works on a more abstract level than just
> recompiling all units depended on, it's where the speed of compiling pascal
> comes from.

In comparison with C/C++, "uses" summarizes the #include of header files
and the dependency checks of Make. But it's not only found in Pascal,
e.g. Java has "imports" for almost the same purpose. The original Wirth
Pascal had no "uses", it was added later.

Many properties make Pascal compilers faster than C/C++ compilers. The
effect of "uses" is equivalent to C/C++ precompiled header files.


> > The only *disadvantage* of units are the current Pascal compilers, which
> > cannot handle circular unit references :-(
> 
> No, it's an advantage: it makes the code and design clearer, plus it
> increases the speed of compilation a *lot*.

I wouldn't call a design clearer when it requires to implement most of a
project in a single unit :-(

I also doubt about the speed increase, as long as nobody tried to write
an Pascal compiler that can handle circular unit references.

DoDi






More information about the fpc-devel mailing list