[fpc-devel] interfaces vs classes in dll

Vincent Snijders vsnijders at quicknet.nl
Fri Nov 30 11:47:39 CET 2007


Michael Van Canneyt schreef:
> 
> I find classes more natural than interfaces. It 'just works'. 
> Not so with interfaces, because you must do a typecast every time.
> 
> Compare
> 
> Function GetPluginInterface : ISOmeThing;
> 
> begin
>   X:=MyPluginObjectXYZ.Create;
>   Result:=X as ISomething;
> end;
> 
This is then a weakness in the language. Because MyPluginObjectXYZ implements 
ISOmeThing and the compiler nows that, you should be able to write just

Result := MyPluginObjectXYZ.Create;

> With
> 
> Function GetPluginInterface : TSomeClass;
> 
> begin
>   Result:=MyPluginObjectXYZ.Create;
> end;
> 


Vincent



More information about the fpc-devel mailing list