draft proposal for ref counting in D
Walter Bright
newshound2 at digitalmars.com
Wed Oct 9 19:18:11 PDT 2013
Rainer Schuetze wrote:
On 28.06.2013 13:37, Michel Fortin wrote:
> Le 28-juin-2013 à 4:55, Rainer Schuetze <r.sagitario at gmx.de> a écrit
> :
>
>> What happens if the class also implements interfaces? A reference
>> of the interface type must do reference counting as well. So the
>> interface must also define AddRef and Release. This is currently
>> true for COM-interfaces derived from IUnknown, but not for other
>> interfaces.
>
>
> I would assume if an object of a reference-counted class cannot be
> cast to its base non-reference-counted class that it'd be the same
> for casting to non-reference-counted interfaces.
>
Yes, that is probably the way to go. But that makes using protocols like COM
difficult in safe mode. We have already talked Walter into not linking reference
counting to AddRef and Release, but if it is implemented with other methods,
these cannot be added to the already existing COM interfaces. Passing or getting
interface pointers to/from external code being unsafe sounds ok, but passing
around these interface references in D code would be unsafe as well.
Adding aliases or non-virtual wrappers to the interface declaration to forward
reference counting to AddRef/Release might help but could also introduce
ambiguities in a class that derives both from a reference counted base class and
an interface like this.
More information about the Digitalmars-d
mailing list