[Lazarus] Strange dependency of units

Martin lazarus at mfriebe.de
Mon Apr 2 18:21:33 CEST 2012


On 02/04/2012 16:51, Jürgen Hestermann wrote:
> Martin schrieb:
>
> >  So by using Grids, you should expect all the platform/GUI dependent 
> stuff to end up in your application.
>
> I am not even aware of all the platform/GUI dependent stuff. I just 
> wanted to use TStringGrid types. Do I need to study the whole LCL in 
> detail to write programs with Lazarus? It seems so.

Well the "whole LCL" seems exaggerated, but yes, in this case I can 
confirm you need more knowledge, as may seem desirable.

Note: Just adding interfaces only hides the issue. It can (or may in 
future) mean a lot of code added to your app. If you add interfaces, 
then you must make sure to use the NoGUI widgetset, to avoid that.

In so far, it is actually "good" (compared to no feedback) that it 
fails, as it gives you the feedback something undesirable is about to 
happen.

Better/Correct would be a proper message, asking what to do. (Well, that 
is, as I wrote, subject to contribution)


>
> > And there are cases where smart-linking does not work. And you 
> encountered one. Some of the methods, of some classes in Grids can not 
> be smart linked (IIRC virtual/overridden class methods, maybe all 
> virtual/overridden).
>
> Smartlinking is not the issue here (because that only affects the size 
> of the file) but it seems that the concept of virtual methods broke 
> the mechanism of units.

Well the size of the file, and which parts of the unit are used appear 
to have a relationship.
Also the smartlinking issue is only one possible explanation.

But the error message is clear: platform dependent code is included.

> > For this cases the "NoGui" widgetset exists. It provides (or should 
> provide) empty methods for this.
>
> But how should I know that this is necessary? I used a simple unit in 
> a console application. And the error messages gave no hint what is wrong.

Well it may need to be added to documentation.

Same applies if you use TTimer, it is widgetset dependent.
Using a component or a unit, requires the user to check what the 
requirements are.
Just because some are self explaining, does not mean that all have to be.

For all I can see: You may have a case about missing documentation

In any case:
as said before, there is no rejection about the fact that it could be 
improved. (subject to someone wanting to do the work)




More information about the Lazarus mailing list