[fpc-pascal] question with interfaces, hooks
david at artoflivingla.org
Wed Jul 15 20:58:38 CEST 2015
Thanks, Graeme and Sven!
On 07/14/2015 11:05 PM, Sven Barth wrote:
> Not related to your problem, but important nevertheless: you don't need
> to free interface variables. They are reference counted and freed
> automatically at least if you don't mix a class reference (in your case
> to t_foo_base) and interface reference (in your case i_foo) which you
> shouldn't do anyway (and which you aren't doing in your example).
Hmm, I just followed the example here:
In that example I guess the TRealClass.Destroy is unnecessary?
I also do not understand what you mean by mixing a class reference and
an interface reference; hopefully I will not do that.
> I haven't work with delegation much, but you could try to do "(fc as
> i_foo).foo;". Also you might want to take a look at TAggregatedObject.
As seen in the example, i_foo(fc).foo works, which seems more or less
equivalent to (fc as i_foo).foo.
I'm looking at TAggregatedObject, and getting deeper into this,
wondering what the real purposes are of these features. I have been
wanting multiple inheretance, and using a "hook...implements" is the
closest thing available. But there seems to be more to it than that. Is
there any recommended reading on the subject of interfaces, delegation,
etc? Any example code that shows the power of interfaces or
TAggregatedObject in a somewhat useful example?
More information about the fpc-pascal