Delphi: do not mix interfaces and classes part X
Posted by jpluimers on 2018/03/15
A very interesting discussion on what the mixing of interfaces and classes can get you into: [WayBack] I’ve got an interface with generics which accepts classes:IMyGeneric = interface…..end;What I want to do is to allow this interface to… – John Kouraklis – Google+
TL;DR: do not mix interfaces and classes.
As often, Asbjørn Heid chimes in showing some insight on clever mixing of the two with sample code accepting an unconstrained type. Don’t do that unless you really know what’s going on behind the scenes.
–jeroen
[WayBack] http://paste.ie/view/707f3afe
thaddy said
Note this only applies to COM interfaces and not to CORBA. The latter being not reference counted anyway.
jpluimers said
Thanks for mentioning that. CORBA has been so long ago, that I forgot how it managed instance lifetime (:
jpluimers said
In a share of that thread at https://plus.google.com/+CHUACheeWee/posts/CuSPdLUn7qD [WayBack, Dalija Prasnikar mentions:
jpluimers said
Chee Wee Chua mention on the G+ thread https://plus.google.com/+JeroenPluimers/posts/TuCkGzQCa3Y [WayBack] that he blogged about this as well:
[WayBack]Something to ponder: using interfaces with class type variables
I think this is related to what he writes: Should the compiler hint/warn when passing object instances directly as const interface parameters? [WayBack]