[fpc-devel] Circular references and forward declarations
Marco van de Voort
marcov at stack.nl
Tue Jan 5 21:42:19 CET 2010
In our previous episode, Juha Manninen said:
>
> You should try to separate user interface from program logic.
> Do only strictly UI specific stuff in form class units. Keep program logic in
> separate units (or one big separate unit :-)).
> Then program logic unit can reference freely the form units, and form units
> can reference the logic unit only from implementation section.
> Thus, no circular reference.
If you read the helpful "add language feature" faq
( http://www.freepascal.org/faq.var#extensionselect )
mentioned earlier, you'll notice that it advises to work out at least a full
proposal, and keep the idle arguing to a minimum.
Note that there is also an hint about making examples with multiple units.
It's there for a reason, trust me.
There is more to splitting source up into separately compilable files than
meets the eye, since e.g. resolving the circular dependancies between
classes must result in exactly the same the order of fields, no matter the
what the order of files is. And orders that are not possible must be flagged
as such.
7
How hard this kind of stuff is, is shown by the fact that after 25 years,
and several periods of commercial sponsorship, gcc still has no precompiled
headers standardly.
The rules that Borland like Pascal's have (no preprocessor state per
compilation but per compilation unit), and the circular dependancy rules are
some of the rules to make this complex matrix of fog a bit more transparent.
Which is why FPC DOES have precompiled headers since before I can remember
(97/98).
More information about the fpc-devel
mailing list