[fpc-pascal] Interface performance

Tony Whyman tony.whyman at mccallumwhyman.com
Fri Nov 11 10:31:13 CET 2016


You'll find a couple threads earlier this year in heated debate about 
interface delegation and how it is implemented. My conclusion was to 
avoid interface delegation - there are just too many traps for the unwary.

There is also another thread bemoaning some odd features about the 
"supports" function.

In use, once you have a variable containing a reference to an interface, 
it behaves, for the most part, the same as a reference to an object 
supporting the same methods and properties and should be used as such.

Tony Whyman


On 11/11/16 08:25, Ryan Joseph wrote:
> I did some experimenting this morning and found out I could pass references to the interface and call methods directly without using Supports and incurring the string compare penalty. There’s also interface delegation I read about and using “implements” keyword but I couldn’t understand what the purpose of this is and why it’s even useful.
>> On Nov 10, 2016, at 6:45 PM, Ryan Joseph <ryan at thealchemistguild.com> wrote:
>> Some times when I want to communicate with a class I don’t have full scope access to I’ll use interfaces and the Supports function to call a method. I’ve noticed however that the string compare function that it is used to find the interface in the class is very slow and makes them not useable for high performance situations. Is there a better way to do this or should I not use interfaces like this in FPC?
> Regards,
> 	Ryan Joseph
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

More information about the fpc-pascal mailing list