[lazarus] LCL circles

Marc Weustink marc.weustink at cuperus.nl
Fri Oct 25 08:28:03 EDT 2002

+ From: Mattias Gaertner [mailto:nc-gaertnma at netcologne.de]


+ The trick circle Interfaces.pp <-> LCL:
+ I guess, only the developers know about this one and its purpose, so
+ here is the story:
+ The LCL is the basic component set. The widget interfaces (gtk, gnome,
+ win32) lie above the LCL and use directly the LCL units. And the LCL
+ communicates to the interfaces via the abstract TInterfaceBase object.
+ This object is created in interfaces.pp. When compiling the LCL the
+ interfaces.pp of the abstract directory is used.
+ When compiling one of the real interfaces (e.g. gtk) the abstract
+ interfaces.ppu in the lcl/units directory is deleted and a gtk-specific
+ interfaces.ppu is created in lcl/units/gtk.
+ When you compile an LCL application the compiler finds 'forms' in the
+ uses section and loads lcl/units/forms.ppu, which uses 'interfaces'. But
+ this time the compiler uses the interface specific
+ lcl/units/gtk/interfaces.ppu, which would normally be impossible,
+ because this is a forbidden pascal unit circle:  forms -> interfaces ->
+ gtkint -> forms

It is not realy a forbindden circle, more an unwanted circle.

Forms reffered to iterfaces in its implementation section.

+ The advantage of this trick is:
+ - In the program source (.lpr) you don't need to add 'interfaces'.
+ The disadvantages of this trick are:
+ - The interfaces.pp must be compiled several times to make sure,
+   that the compiler syncs all units. This is the reason, why you
+   can't add lcl and lcl/interfaces/gtk to the unitpath.

For normal apps, this shouldn't be a problem.

+ - The compilation is somewhat tricky and so the Makefiles are
+   more complicated.


+ - Forcing the compiler to create a forbidden pascal circle is IMHO
+   a bad example for coding.

See above.

+ I hope this was not too negative. I don't want to offend someone,
+ because of coding style. This is open source, so everyone can write if
+ he/she thinks that something can be done better.

I don't feel offended :-)

The reason for the construction as it is now is pure historical. While the
project grew,  more and more knowledge of the LCL was needed in the
interface {*}. Since we were developing only for a GTK set, this could be
compiled in one go (interface and LCL).
Problem introduced here is that one needs a compiled LCL for every
widgedset. So if one wants to make an app for different widgetsets, one has
to have all the different binary LCL's. With the current solution one has
one LCL (and onle different interface units)

{*} And still IMO when the interface has more common functions and/or events
the interface doesn't have to know anything about the LCL. And there would
be no circle.


More information about the Lazarus mailing list