named arguments, string interpolation, please stop.

Richard (Rikki) Andrew Cattermole richard at cattermole.co.nz
Thu Jan 11 23:19:10 UTC 2024


On 12/01/2024 12:09 PM, Jonathan M Davis wrote:
> @nogc doesn't even prevent collections running while a function is 
> called. It just prevents that specific function from triggering the 
> collection (thanks to no allocations triggering it). Another thread 
> could trigger a collection while that function is running. So, yes, in a 
> single-threaded program, it's equivalent to calling GC.disable, but in 
> the general case, it isn't.
> 
> 
> So, anyone actually relying on @nogc preventing collections is arguably 
> asking for trouble even with the current GC - though it seems like the 
> kind of folks who like to use @nogc are often the kind of folks who are 
> likely to avoid the GC entirely, so if @nogc is used everywhere in their 
> code, then they won't end up with either GC allocations or collections. 
> However, anyone using it selectively really can't rely on it to avoid 
> collections unless their program is single-threaded and will always 
> remain so.

Yes.

It is fundamentally an attempt at informed consent at using the GC in 
selected code.

Which it does a terrible job at.


More information about the Digitalmars-d mailing list