[Lazarus] IUnknown and reference counting

Kostas Michalopoulos badsectoracula at gmail.com
Thu Mar 21 14:48:26 CET 2013


Thanks, i understand that. My question is, can i somehow make FPC to add
AddRef/Release calls also to TBlah so i can use refcounting with a class
just like i would use it with an interface? Is there some technical
limitation on why this is only done with interfaces and not all objects
that descend from a refcounted interface?


On Thu, Mar 21, 2013 at 2:38 PM, Sven Barth <pascaldragon at googlemail.com>wrote:

> Am 21.03.2013 14:23, schrieb Kostas Michalopoulos:
>
>  Yes, that is what i mean with "topmost" type: if you look at the
>> inheritance as a tree, TInterfacedObject is the topmost (or root, if you
>> think of it as an upside-down tree) of the type hierarchy. In this code
>>
>>   type
>>     IBlah = interface ... end;
>>     TBlah = class(TInterfacedObject, IBlah) ... end;
>>
>> TBlah is an IBlah, so i'd expect it to behave like IBlah.
>>
>
> And it behaves like an IBlah, because you can assign a TBlah to every
> variable or parameter that expects a IBlah.
> The point however is that the compiler only inserts calls to AddRef and
> Release (which are provided by the base interface IUnknown/IInterface and
> of which every (COM) interface is derived) if the variable you work with is
> of an interface type.
>
>
> Regards,
> Sven
>
> --
> ______________________________**_________________
> Lazarus mailing list
> Lazarus at lists.lazarus.**freepascal.org<Lazarus at lists.lazarus.freepascal.org>
> http://lists.lazarus.**freepascal.org/mailman/**listinfo/lazarus<http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20130321/3734678e/attachment-0003.html>


More information about the Lazarus mailing list