[fpc-pascal] Please someone explain this to me

Michael Van Canneyt michael at freepascal.org
Thu Feb 11 11:47:14 CET 2016



On Thu, 11 Feb 2016, Anthony Walter wrote:

> Michael, a question:
>
> How much of the interface section of units differ per platform? Is it 1% of
> the code? Is it 5% of the code? With the xml2 unit it's 0%, yet all of the
> declarations are nested in several layers of include files:

Numbers are irrelevant. A particular system is adhered to. 
It's clearly not your system, but then, one could point out that it's not your code either.

Obviously, I cannot speak for Lazarus' LCL units.

I can only speak for the RTL units.

The files are like this for maintainability:
- Platform dependent parts will always be in separate include files.
   Forget IFDEF. The few parts where it is used are ugly enough as it is.
- Some interface parts are shared between units: see the unix-specific units
   as explained by Marco. Sysutils shares e.g. a part with the Strings unit.
   the DOS unit shares a part with the System unit, if memory serves
   correctly.
- Smaller files reduce the risk of conflicts when committing changes.
   While it is common for 2 people to work on sysutils or system,
   it's already less common that they work on the same functionality.

As said before, these files are organized for the sake of their maintainers.
Not the users. What the maintainers deem best, will be used.

Allow me to express some surprise at the vehemence with which you attack
this perceived problem.

First, it's not like the identifiers are distributed randomly over arbitrary include files.
They are neatly grouped in logical units.

Second, if you want a nice overview of what is implemented in a unit: 
the documentation is guaranteed to be complete at the time of release, 
and contains an index per unit and even of all identifiers in the RTL. 
The sysutils unit documentation contains some topics with 'groups' of functionality.
(suggestions always welcome)

In Delphi, that's what I also do if I need an overview; I open the help, and that's it.
Only in the very last instance - if I am interested in the actual particulars of an
implementation - then I open the source.

And honestly, I cannot even remember when I had to look up something in
sysutils or system. I expect experienced people to know these units better 
than the back of their hand. For beginners I think documentation is better
suited.

Michael.



More information about the fpc-pascal mailing list