DIP60: @nogc attribute

Dicebot via Digitalmars-d digitalmars-d at puremagic.com
Thu Apr 17 11:00:24 PDT 2014


On Thursday, 17 April 2014 at 17:48:39 UTC, Ola Fosheim Grøstad 
wrote:
> On Thursday, 17 April 2014 at 15:49:44 UTC, Dicebot wrote:
>> put() may call GC to grow the buffer, this is the very point. 
>> What is desired is to check if anything _else_ does call GC, 
>> thus the "weak @nogc" parallel.
>
> What do you need that for?

As a middle-ground between hard-core low level real-time code and 
applications that don't care about garbage at all. As soon as you 
keep your buffers growing and shrink only occasionally "GC vs 
malloc" issues becomes less important. But it is important to not 
generate any actual garbage as it may trigger collection cycles.

Such weak @nogc could help to avoid triggering allocations by an 
accident and encourage usage of output ranges / buffers. 
Currently code in Sociomantic uses similar idioms but having 
compiler help to verify it would help in my opinion.

>>> Of course, resorting to templates requires some 
>>> thinking-ahead, and makes reuse more difficult.
>>
>> I don't see how templates can help here right now.
>
> Wasn't the problem that the type-interface was less constrained 
> than the type-interface allowed by a @nogc constrained function?

No, this is something completely different, see my answer before.


More information about the Digitalmars-d mailing list