[fpc-pascal] Interface performance

Ryan Joseph ryan at thealchemistguild.com
Fri Nov 11 10:46:44 CET 2016


> On Nov 11, 2016, at 4:31 PM, Tony Whyman <tony.whyman at mccallumwhyman.com> wrote:
> 
> 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.

I just don’t plain get it. The examples given seem to be a redundant property that could be replaced with a reference the interface itself.

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

The string lookup absolutely murders performance (I was using “cobra” interfaces) so it can’t be used in some situations.

> 
> 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.

Just as I got this message I’m running into some inexplicable memory related crashes casting from interfaces to objects and calling methods.  Are you sure you can just cast these around like that? The compiler seems to get confused and lose track of what the type actually is. In my first test this didn’t happen and I was able to use an interface as a type then cast it to an object, pass to a function and call a method. In the 2nd example the variable went from a couple classes first and died at the end. Seems very unstable.

Regards,
	Ryan Joseph




More information about the fpc-pascal mailing list