Warn about using the GC

Daniel N no at public.email
Sun Jan 14 19:35:24 UTC 2024


On Sunday, 14 January 2024 at 18:58:11 UTC, Walter Bright wrote:
> On 1/14/2024 1:44 AM, Daniel N wrote:
>> On Sunday, 14 January 2024 at 09:25:18 UTC, Walter Bright 
>> wrote:
>>> Instead of using @nogc, we could have a compiler switch "warn 
>>> on use of GC" which you can turn on if you like, or not, or 
>>> turn on the -w switch to treat the gc warnings as errors.
>> 
>> What if you use @nogc in the hot-path but want to use gc 
>> during initialization?
>
>
> The choices are:
>
> 1. throw -wgc switch and get a warning for every use of the GC
>
> 2. -wgc -w and get errors for every use of the GC
>
> 3. compile the gc and non-gc modules separately, using the 
> warning switches for the latter
>
> 4. disable GC collections on the hot path with 
> GC.disable()/GC.enable()
>
> 5. use @nogc and transitively prevent any GC use at all on such 
> functions
>
> 6. forcibly cast away @nogc and use the GC anyway
>
> Surely one of those will work for you!

Yes, I use 5 and it works great thanks! I was under the 
impression that you considered removing @nogc, glad that wasn't 
the case.



More information about the Digitalmars-d mailing list