helo,
I just had a look at Nim some few days ago and like it quite much. I also like too look at D. In D by default the GC does the memory management, but you can overrule the GC by deregistering objects from the GC (then you have to deallocate it yourself) or you can switch to manual memory mangement by attaching a @nogc annotation to some method. That gave me the idea whether it would be possible or would be an idea to have something like an @arc annotation in Nim you can attach to some method. So by default the GC is turned on, but you can overrule it and stick to ARC in some method annotated with @arc. This you would do in case some piece of code runs slow with the GC.
Just an idea ... Regards, Haddock
Okay, from reading about memory management in Nim from this page https://nim-lang.org/1.4.8/gc.html I conclude that you have to define with a --gc flag whether to let one of the available GCs do >all< the memory management automatically or >everything< be ARC. My case is this: some application writen in Nim is started up using one of the available GCs. From now on >all< memory management is done be the selected GC. This is fine for the most part of that application except for some few functions that need to be especially efficient or more efficient than they are when using a GC.
So the application is started up letting some GC do all the memory management work, but for those few functions that need to be especially efficient I can manage memory using ARC instead. By applying some annotation to those functions may called @arc the overhead caused by the GC no longer applies, but more eficient ARC is made use of. What do you think of this idea?
A more up to date version of this document is here: https://nim-lang.org/2.2.0/mm.html
In summary, your idea is based on an outdated mental model. Nim's default works well with custom containers and there is nothing to worry about as it's entirely modular: Optimize hotspots as required the rest of the runtime won't interfere with any stop-the-world or tracing mechanisms.