I think I asked this some years ago but I came across it again I just don’t get
what the point of this is. There is an “implements” property but it seems like
yet another half-baked feature from Delphi that wasn’t implemented completely
or is broken. What’s the point of implementing an interface like this on
TBaseClass if you need to access all the methods by using the property name
(“hook” in this case) when you could just add an instance of THook in
TBaseClass? It adds so much noise and clutter in the language and for what? The
only reason it makes sense is if you could call “base.DoIt” and omit the .hook
every time you’re typing but that was overlooked for some reason. Why??
type
IHook = interface ['IHook']
procedure DoIt;
end;
type
THook = class (IHook)
procedure DoIt;
end;
procedure THook.DoIt;
begin
writeln(ClassName+' did it');
end;
type
TBaseClass = class (IHook)
private
m_hook: IHook;
public
property Hook: IHook read m_hook implements IHook;
constructor Create;
end;
constructor TBaseClass.Create;
begin
m_hook := THook.Create;
end;
base: TBaseClass;
base := TBaseClass.Create;
base.DoIt; // CANT DO THIS
base.hook.DoIt; // MUST DO THIS
Regards,
Ryan Joseph
_______________________________________________
fpc-pascal maillist - [email protected]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal