On tiistai, 5. tammikuuta 2010 20:20:16 Jonas Maebe wrote:
> It would have at least two consequences (there are undoubtedly more that
>  I'm not thinking of currently): a) all forward-declared types from the
>  interface would have to be resolved after the uses-clause in the
>  implementation has been parsed (because only at that point all classes
>  would be known) b) this would cause the interface crc of those units to
>  change (since the types change once they are resolved), which means that
>  every unit containing such a construct (and every unit depending on them,
>  even if they don't touch these types) would be recompiled at least once
>  (some immediately in case of circular interface-implementation unit
>  references, some only when you recompile the project)
> 
> This wouldn't double the compilation time, but it would probably slow down
>  things quite a bit. I'm also not sure whether the ppu storing/logic logic
>  would still work if it could be called at a point where not all
>  forward-declared types are resolved. It would probably require special
>  code for that situation.

I realize that you know the compiler better than me, but some more thoughts of 
mine anyway:

The only information needed for the interface section is that the variable's 
type is object (class instance). It could be treated as TObject during the 
interface parsing. The same thing as when forward declaring a class inside a 
unit. The forward declaration only says it is a class, no mention of its 
ancestor, data members or methods.
The class's members are used only in implementation section, but there the 
class's "home unit" is included in uses clause already and it is no different 
from the current situation.

Ok, I understand the class's member info is stored somewhere at the end of 
interface section, the compiler would need more fundamental changes if that 
info was not available then.
But still, the same space is reserved for a variable of any object, be it 
TObject or TMyClass. If I only could tell the compiler that my variable is 
actually TMyClass, not TObject, and then use code completion features and 
avoid casting.
Hey, there could be an Alias syntax. First, in interface:
  MyVar: TObject;
Then in implementation section:
  MyVar = alias TMyClass

... not very good. The point is anyway that my variable is basically a pointer 
to an object and the compiler should understand that.


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

Reply via email to