On 05 Jan 2010, at 17:07, Juha Manninen wrote:

Forward declaration of a class is allowed inside a unit. There can be a
reference to a class before it is defined! Like:
 TMyClass = class;

Why is it not allowed from another unit? They are conceptually the same thing!

The reason that they are conceptually not the same thing is that in Pascal two different units can both declare a different class with the same name (just like they can both have global variables and procedures/functions in the interface with the same name). You would at least have to do something like one of the following a) use one global name space for all classes (i.e., forbid that two different units used in a program declare a class with the same name anywhere), or b) add some way to specify the unit name in which this external class is specified, or

There might be other solutions (maybe some kind of class-specific namespace support), but it would definitely require some more language features rather than merely accepting anonymous class definitions anywhere. Otherwise the type checking is going to run completely haywire.


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

Reply via email to