[fpc-devel] Circular references and forward declarations

Michael Van Canneyt michael at freepascal.org
Wed Jan 6 12:14:18 CET 2010

On Wed, 6 Jan 2010, Juha Manninen wrote:

> On keskiviikko, 6. tammikuuta 2010 12:42:23 Florian Klaempfl wrote:
>> Juha Manninen schrieb:
>>> Still, best solution has been to put everything into one big file. And
>>> still, I don't like that compiler forces such a thing.
>> The compiler forces you many other things. Still, I don't get what's the
>> problem with a large unit if it's really needed (and nothing like
>> abstract base classes or interfaces or type casts or ... helps). Stuff
>> closely depending on each other should end in the same unit. You even
>> cannot test a unit with external circular class references without the
>> other involved units. So why should the stuff be separated?
> I must admit this is a good point. This is more of a cultural issue between
> programming languages.
> If the tool chain supports big source files and if people accept them, there
> is no problem.
> <OOT> I hope Lazarus can soon edit parts of one file in many editor tabs.
> </OOT>
> Other programming languages have different cultures. See the comment from my
> original post in this thread. It was from a professional programmer and I
> understand it. Some development teams want to put every class into its own
> file. C and C++ even have headers in separate files (which is messy IMO).
> So, if a professional team chooses a programming language / environment for a
> project, this one feature can make a strong point against Object Pascal.

Why ? Every class in 1 file is perfectly possible with include files, and 1 
big unit file.

If someone comes from C this should not be a problem, since every C file
simply is an include file, header file or not. There are no "privileged
files". In pascal there are: the unit and the program. The unit is called
'unit' because it 'unites' a set of routines that are closely interrelated.

Honestly, I don't understand what the fuss is all about. You can make it
as complicated or as simple as you want, it is all up to you.


More information about the fpc-devel mailing list