RFC: reference counted Throwable

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Sun Sep 21 11:39:07 PDT 2014


On 9/21/14, 11:20 AM, Adam D. Ruppe wrote:
> BTW hmmm what about this:
>
> interface Foo { }
>
> class Bar : Foo, RCObject {}
>
> class Pwned : Foo {}
>
> void main() {
>     Foo bar = new Bar();
>     /* where is bar.Release() called? */
>     Foo pwned = new Pwned();
>     /* better hope pwned.Release() isn't called cuz that's impossible */
> }
>
>
> I *believe* IUnknown interfaces are special and a separate category from
> regular D interfaces, so this would be statically disallowed.
>
> But with the RCObject, we need to be careful about implicit casting to
> interfaces transparently killing memory safety.

Good point.

> of course then we might be weakening their usefulness. gah we just need
> scope references, then we can pass the interface with confidence that it
> won't be escaped. yeah yeah i know i sound like a broken record.

I don't think scope references are workable. I'll explain why in a 
latter post.


Andrei



More information about the Digitalmars-d mailing list