DIP60: @nogc attribute

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Sat Apr 19 10:41:59 PDT 2014


On 4/19/2014 6:14 AM, Dicebot wrote:
> On Thursday, 17 April 2014 at 22:04:17 UTC, Walter Bright wrote:
>> On 4/17/2014 1:03 PM, John Colvin wrote:
>>> E.g. you can implement some complicated function foo that writes to a
>>> user-provided output range and guarantee that all GC usage is in the control of
>>> the caller and his output range.
>>
>> As mentioned elsewhere here, it's easy enough to do a unit test for this.
>
> Erm, no? You can possibly track GC calls by using custom druntime fork but you
> can't track origins of such calls in source tree without compiler help.

@nogc is there to help.


>>> The advantage of having this as language instead of documentation is the
>>> turtles-all-the-way-down principle: if some function deep inside the call chain
>>> under foo decides to use a GC buffer then it's a compile-time-error.
>>
>> And that's how @nogc works.
>
> And it is not good enough for practical reasons, i.e. we won't be able to use
> @nogc for most of the Phobos.

The first step is to identify the parts of Phobos that unnecessarily use the GC. 
@nogc will help a lot with this.


More information about the Digitalmars-d mailing list