named arguments, string interpolation, please stop.

Adam Wilson flyboynw at gmail.com
Thu Jan 11 22:02:16 UTC 2024


On Thursday, 11 January 2024 at 21:37:01 UTC, Walter Bright wrote:
> On 1/11/2024 1:18 PM, DrDread wrote:
>> this is discarding the use case that you want to mark only 
>> parts of your codebase nogc, but enforce it'S really nogc. we 
>> do use some realtime threads, but the rest off the app is @gc.
>
> This subthread suggests to me that the problem with @nogc is it 
> works.

@nogc works just fine. We recently spent a good chunk of time in 
Discord educating a newbie on what it *actually* does.

What @nogc is specified to do: Prevent GC allocations from 
occurring. Fantastic.
What people actually do with @nogc: Use it to selectively disable 
the GC without using GC.disable().

The reason for this stems from a side-effect of how the *current* 
GC operates. Because allocations are the trigger for collections, 
by preventing allocations, collections are also prevented. And 
what people really want to do is disable collections because they 
don't like the collection pauses. They don't *actually* care 
about the allocations per se because that is generally as fast as 
a malloc and they are going to have to allocate at some point 
anyways.

So @nogc works exactly as specified, but because of an 
unspecified implementation side-effect, that is not guaranteed to 
hold true in the future, the @nogc crowd writes their code as if 
@nogc does something else entirely.  And we end up here in this 
thread.


More information about the Digitalmars-d mailing list