DIP60: @nogc attribute

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Thu Apr 17 15:52:10 PDT 2014


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.


More information about the Digitalmars-d mailing list