On 14 Aug 2009, at 08:43, Graeme Geldenhuys wrote:

I can't agree more. Sometimes there is a valid design for something like that. The compilers already handle forward declarations in the same unit,

Actually, only in the same "type" block.

so why can that not be applied for multiple units as well.

Because types with the same name in different units are different types in Pascal.

Suchfunctionality will probably be added for Objective-Pascal classes (in the form of external anonymous objcclass types, because otherwise it's very hard to make sensible automated translations of Objective-C framework headers to Pascal; single giant umbrella units don't work very well there), but there it can work because the type system of Objective-C works differently. It has one namespace for class names, which is global for the entire application because all classes have to be registered with the run time system based on their name. So in Objective-C, a class name by itself does refer to a unique type (and the compiler will give an error if you try to define a class with the same name twice in different units).

In regular Object-Pascal, class names do not have to be unique over the entire application. Letting the compiler guess which type is the external one you meant and which isn't is a recipe for disaster. It would probably also require a significant rewrite of the type handling and symbol table (even more so than what will be required for objcpas).


Jonas
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to