[Lazarus] Strange dependency of units

J├╝rgen Hestermann juergen.hestermann at gmx.de
Sat Mar 31 15:08:00 CEST 2012

 >> How should anybody know that this is required in this situation?
 >> Why is the INTERFACES unit not required in the unit itself?
 > Grids is part of the platform independent LCLBase.
 > The unit 'interfaces' (i.e. package LCL) provides the
 > implementation.

How should I know this?

And why do I *not* need the INTERFACES unit in my general purpose unit? 
There I only 'use' GRIDS.

 > It is similar to a class like TStrings with abstract methods and
 > a full class like TStringList.
 > The compiler can tell that "TStrings.Create" is a bad idea, but it can
 > not tell what full class to use instead.
 > It's the same with Grids. The compiler can tell that the implementation
 > is missing, but you have to choose the implementation.

Well, I don't know anything about packages. I come from Turbo/Virtual 
Pascal. I always struggle with this very strange concept of packages. It 
seems that it generates more problems than it saves. I only want to use 
libraries (units). It was just a great step forward with Turbo Pascal to 
introduce the concept of units. No need to think about dependencies 
anymore. If you use a unit that again uses other units the compiler/IDE 
took care about these things and the only need was to configure where to 
search for them (which was already done for libraries that came with the 
IDE). In case it missed the source of a unit it clearly told me *which* 
unit it could not compile. But now I have to fight with these internals 
myself. I have to learn all about used packages (which units do they 
include? which dependencies exist? etc.) even when I'm writing a simple 
'Hello World' program that uses a simple unit. Strange.

 > Hint: When you use Cody to add the grids unit to the uses section, it
 > will automatically add the LCL as dependency.

What is Cody? As said: I added the 'uses grids' clause to my unit only. 
I don't need it in my simple console program. I also never added the 
grids unit to my other programs. The compiler should know what it has to 
compile (and link) because it was declared in the unit. If I create a 
graphic program with Larazus' 'new project' function the INTERFACES unit 
is added automatically to the program (but no GRIDS!). But if I create a 
new console program and then use my unit (because I need some non-grid 
functions) I get errors but don't know what they are all about.

More information about the Lazarus mailing list