DIP60: @nogc attribute

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Thu Apr 17 17:09:56 PDT 2014


On Thu, Apr 17, 2014 at 03:52:10PM -0700, Walter Bright via Digitalmars-d wrote:
> On 4/17/2014 3:18 PM, Steven Schveighoffer wrote:
> >During the entire processing, you never increment/decrement a
> >reference count, because the caller will have passed data to you with
> >an incremented count.
> >
> >Just because ARC protects the data, doesn't mean you need to
> >constantly and needlessly increment/decrement references. If you know
> >the data won't go away while you are using it, you can just ignore
> >the reference counting aspect.
> 
> The salient point there is "if you know". If you are doing it, it is
> not guaranteed memory safe by the compiler. If the compiler is doing
> it, how does it know?
> 
> You really are doing *manual*, not automatic, ARC here, because you
> are making decisions about when ARC can be skipped, and you must make
> those decisions in order to have it run at a reasonable speed.

I thought that whole point of *A*RC is for the compiler to know when ref
count updates can be skipped? Or are you saying this is algorithmically
undecidable in the compiler?


T

-- 
"You are a very disagreeable person." "NO."


More information about the Digitalmars-d mailing list