DIP60: @nogc attribute

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Fri Apr 18 17:17:59 PDT 2014


On 4/18/2014 5:30 AM, Steven Schveighoffer wrote:
> Absolutely not, the compiler knows whether the count needs to be incremented, I
> don't need to know.

But there are manual escapes from it, meaning you need to know to use them:

    unsigned char *vdata = data.data;
    // process vdata

I am skeptical that the O-C compiler is sufficiently smart to make ARC on all 
pointers practical. That snippet pretty much proves it.

Total replacement of GC with ARC in D will:

1. Be a massive change that will break most every D program
2. Require people to use unsafe escapes to recover lost performance
3. Require multiple pointer types
4. Will not be memory safe (see (2))
5. Require the invention of optimization technology that doesn't exist
6. Become more or less ABI incompatible with C without a long list of caveats 
and translations

and, to top it off, as the paper Andrei referenced pointed out,
it may not even be faster than the GC.

It has the very real likelihood of destroying D.

A much more tractable idea is to implement something like C++'s shared_ptr<> as 
a library type, with usage strategies paralleling C++'s (and yes, use of 
shared_ptr<> would be unsafe).


More information about the Digitalmars-d mailing list