Functions annotated with ".nogc." can't do any operations that rely on garbage collection.
Similar to how nogc works in D lang:
Implementation would probably be similar to how the ".noSideEffect." pragma already works in Nim.
And then what? What's the point? We have --gc:none and looking at the compiler warnings.
The point - A larger subset of Nim stdlib and ecosystem being usable in environments where GC is not acceptable. eg, domains where only C, C++, Rust or Ada may be used.
It would be like "--gc:none" that always becomes a compile error if a given function has that pragma.
But you're right, given that "--gc:none" is available, it's a lot less relevant. People can make github pull requests, or make their own modules where "--gc:none" doesn't give any warnings, for those kinds of environments.
Thanks for the reminder!
That may be useful for e.g. games, where you want to avoid gc in rendering logic, but ok with gc in game logic. noSideEffect is a nice analogy. You don't want to compile all program with noSideEffect.
Not gonna happen anytime soon.
Most helpful comment
That may be useful for e.g. games, where you want to avoid gc in rendering logic, but ok with gc in game logic.
noSideEffectis a nice analogy. You don't want to compile all program withnoSideEffect.