RFC: reference counted Throwable

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Fri Sep 19 22:46:43 PDT 2014


On 9/19/14, 10:24 PM, Walter Bright wrote:
> 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.

Agreed. It has the cost distributed a different way.

> 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. :-)

That's fine. You can't have everything.

> 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.

In nogc mode, everything is ARC so I'm not getting this.

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

That was indeed a crappy argument, and not advanced by me. I'm not 
advocating for that.

> 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.

We need to figure out a design. All I'm saying is we must not bring 
prejudice to the table. And a very basic point is: there will be a way 
to COMPLETELY disable the GC. That is a must.


Andrei



More information about the Digitalmars-d mailing list