RFC: reference counted Throwable
Andrei Alexandrescu via Digitalmars-d
digitalmars-d at puremagic.com
Sun Sep 21 08:03:11 PDT 2014
On 9/21/14, 1:51 AM, Jacob Carlborg wrote:
> On 2014-09-20 18:56, Andrei Alexandrescu wrote:
>
>> Please don't take me in a court of law. But yes, I am talking about the
>> compiler inserting calls to increment and decrement reference counts. --
>> Andrei
>
> We do need to know what you're proposal is for.
The title is an incomplete summary. Exceptions would be transparently
reference counted. I.e. no changes in user code.
A little more detail on a design Walter has put together: define a new
root class RCObject. Neither Object nor RCObject inherit each other. All
classes that inherit RCObject are detected by the compiler as reference
counted.
(For practical reasons, RCObject will implement IUnknown. There are a
few random consequences of that (meaningless method QueryInterface, no
class info, no monitor, COM-compatible layout) but IUnknown already has
AddRef and Release and the compiler already recognizes IUnknown as a
special case. Hooking RCObject there will leave us with two roots
instead of adding a third one.)
Throwable will inherit RCObject. The compiler inserts AddRef and Release
whenever copying RCObject (and derivatives) references around, of course
following a null check.
The caveats discussed previously in http://goo.gl/Xl5U3z do apply.
Andrei
More information about the Digitalmars-d
mailing list