[Lazarus] IUnknown and reference counting
Sven Barth
pascaldragon at googlemail.com
Thu Mar 21 14:15:44 CET 2013
Am 21.03.2013 12:34, schrieb Michael Schnell:
> On 03/21/2013 11:36 AM, Hans-Peter Diettrich wrote:
>>
>> As already mentioned, Delphi interfaces are the workaround for the
>> missing multiple inheritance in OPL,
>
> As you are stating yourself: multiple inheritance does not introduce
> reference counting and automatic create/destroy of an instance,
> interfaces obviously are a rather different concept.
If we put accounting the reference counting aspect then interfaces are
exactly what it says on the tin: a interface (German: Schnittstelle) to
a class. You can see it as a syntactical contract between the class and
the code that uses the class. It also allows you to abstract the
implementation to achieve low coupling ("always program against an
interface"). Also a class can provide multiple different interfaces.
This is the core of what "interface" means.
Now FPC and Delphi add two additional concepts to this:
* reference counting for interfaces (in FPC only those that are not
declared after a {$interfaces corba} directive)
* the ability to delegate the implementation of the interface to a
different class (using the "implements" keyword)
Regards,
Sven
More information about the Lazarus
mailing list