[Lazarus] Strange dependency of units

Mattias Gaertner nc-gaertnma at netcologne.de
Sun Apr 1 12:52:02 CEST 2012


On Sun, 01 Apr 2012 11:20:49 +0200
Jürgen Hestermann <juergen.hestermann at gmx.de> wrote:

> Mattias Gaertner schrieb:
>  > AFAIR Turbo Pascal was pretty simple. I really liked it.
>  > It supported only one target platform and the OOP came with Delphi.
> 
> OOP was already implemented in Borland Pascal.

AFAIK this was only the "object" syntax, not the "class" syntax. IMO
the "object" syntax is too limited to be called true OOP. 
Some people say that javascript is OO, so I guess you can say TP had
OOP.
 
>  > Compare the compiler flags of TP and FPC. TP is a toy compared to FPC.
> 
> But what has all this to do with the concept of packages? The concepts 
> used in TP where enough to allow arbitrary complex applications. 

The concepts of assembler allow that too.


> And my 
> main critic about all this is, that even when new concepts are 
> introduced they should be rock solid. This looks more like a design study.

The concept is pretty simple and works nice since 10 years.

 
>  > The normal user creates a LCL application and everything is setup for 
> him.
> 
> That's exactly what I did. I used Larazus to create a console 
> application. I then added my general purpose unit to the uses clause. 
> Then compile failed with an error message that had nothing to do with my 
> program or unit.

A console application is for simple stdin/stdout programs that runs in
the DOS box, the OS X terminal, the Linux shell, etc.

You did not create a LCL application. When you create a new project,
there is a "Description".

 
>[...]
> I don't know. But still what I did was a standard thing:
> 
> *) Write a unit
> *) Create a program (via Lararus) that uses the unit (which I use in 
> nearly all programs)
> 
> What is wrong with this?

Nothing. The unit just can not work on its own. You just have to
add an implementation.

 
> To sum it up:
> If I use a unit GRIDS in a unit and a program uses this unit how should 
> I know that this program has to use the unit INTERFACES? 

As I wrote two times: It does not need interfaces.
Here is an example that compiles without interfaces:

program project1;

{$mode objfpc}{$H+}

uses
  Classes, Grids, NoGUIWSFactory;

begin
  writeln('Works');
end.


> Why is this 
> unit not required in my unit but in my program? That's completely 
> rediculous. Why does the existing rock solid unit concept no longer 
> work? It seems some other concept has broken it.

Please distinguish between "Compiles" and "Works".

It is not enough to use unit "interfaces", a normal LCL application
also requires an Application.Initialize call.

The unit concept is powerful, but it is not almighty.

Mattias




More information about the Lazarus mailing list