named arguments, string interpolation, please stop.
Walter Bright
newshound2 at digitalmars.com
Thu Jan 11 22:28:24 UTC 2024
On 1/11/2024 2:02 PM, Adam Wilson wrote:
> @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.
Sounds like better documentation is needed for both @nogc and GC.disable().
https://issues.dlang.org/show_bug.cgi?id=24331
More information about the Digitalmars-d
mailing list