Warn about using the GC

Nickolay Bukreyev buknik95 at ya.ru
Sun Jan 14 14:03:05 UTC 2024


On Sunday, 14 January 2024 at 12:47:47 UTC, Richard (Rikki) 
Andrew Cattermole wrote:
> Basically if you pass in a delegate that does not have 
> ``@nogc``, the ``@nogc`` on the function gets removed.
>
> The function body will of course be typed checked as if it did 
> have ``@nogc``.

Sounds reasonable. I guess it can work fine… until you wrap that 
delegate in a struct. Then you are out of luck, just like you are 
now. I suppose to solve this in a general case, you need to 
reinvent Rust.

> This makes it so things like ``opApply``, only need one 
> overload, not say 24 of them to handle all the different 
> combinations of attributes.

Just curious, why 24? +/- nothrow, +/- pure, +/- @nogc, 
@safe/@system—that’s _only_ 16. You can cut it down to 8 if you 
always require @safe (callers will have to provide a @trusted 
callback).


More information about the Digitalmars-d mailing list