RFC: reference counted Throwable

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Fri Sep 19 22:24:05 PDT 2014


On 9/19/2014 9:47 PM, Andrei Alexandrescu wrote:
>> We've had this discussion numerous times before - "throw the magic
>> compiler switch" and D becomes an ARC system and everything is
>> wonderful. It cannot work. ARC and GC are not equivalent.
>
> I think past discussions have been inconclusive at best and must be reopened.

For starters,

1. ARC is slow and generates bloated code.

2. To deal with (1), existing ARC systems allow escapes from it. This has severe 
implications for memory safety. Rust's entire type system appears to be designed 
around trying to deal with this, and AFAIK they're the only ones who have tried. 
C++ shared_ptr and ObjectiveC's ARC are not memory safe. They are not. Not not 
not, and they don't even try. :-)

3. ARC objects require an embedded count. This means they cannot be mixed with 
non-ARC objects. This is fundamentally DIFFERENT from how GC behaves, and we 
cannot pretend or wish this away or add a compiler switch to make it go away.


None of these points were addressed in previous discussions beyond the 
supposition of some nonexistent compiler technology that would make them go away.

D can have ref counted objects, but it will not work with a compiler switch to 
switch them back and forth. They'll have to coexist peacefully with GC objects.


More information about the Digitalmars-d mailing list