[fpc-devel] interfaces vs classes in dll

Marc Weustink marc.weustink at cuperus.nl
Fri Nov 30 11:52:23 CET 2007


Vincent Snijders wrote:
> 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;

Weakness ? I do this all the time in Delphi. No need for as

Marc



> 
>> With
>>
>> Function GetPluginInterface : TSomeClass;
>>
>> begin
>>   Result:=MyPluginObjectXYZ.Create;
>> end;
>>
> 
> 
> Vincent
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-devel
> 




More information about the fpc-devel mailing list