[Lazarus] Circular references

Florian Klaempfl florian at freepascal.org
Fri Aug 14 10:04:18 CEST 2009


Graeme Geldenhuys schrieb:
> Michael Van Canneyt wrote:
>>
>> This is the world upside down. Better tell us exactly why you think
>> this must be possible. the 'Sometimes there is a valid design for
>> something like that' is not an argument at all. Maybe there are other
>> - more valid - ways to accomplish what you want.
> 
> I can give you loads of examples where I had to implement workarounds in 
> Object Pascal to get around that "limitation".
> 
> Have ever tried to write code in a similar fashion as Java does?

This is not how Object Pascal should be used. Or do you miss also 
GWBasic style per line labels ;)?

Those cross unit forward declarations open a can of worms which is 
probably worse than cyclic unit references in the implementation 
section. Its basic design flaw is that it makes the interface of an unit 
dependend on the implementation section and even worse, of the units 
used in the implementation section and their order! And this is usually 
a no-go.

It's easy to come up with some simple example which is easy to handle. 
On the other hand, the simple examples can be solved by other means like 
an abstract base class.

I'am sure there will be dozens of corner cases which confuse (and the 
programmer) the compiler like having a class defined in more than one 
unit. Or combine cross unit forwards with cyclic unit references, maybe 
even generics, sounds to be really dangerous and complicated on the 
compiler side to solve so slowing down the compiler.




More information about the Lazarus mailing list