Re:The Neat Programming Language
by dadoum on Monday December 25, 2023 @08:43PM
(#38768190)
In D you have 2 options to deal with that:
- As you described, you can disable the GC to do your thing. That's not the solution I would recommend, but if you call GC.disable then the GC won't collect anything until you enable it back (or if the program is running out of memory).
- You can mark a function as @nogc, and then the compiler will prevent you from allocating anything that could trigger GC allocation.
There is some level of support for @nogc in the language and few libraries to help, the issue is more in the standard library which relies a lot on the GC.
- As you described, you can disable the GC to do your thing. That's not the solution I would recommend, but if you call GC.disable then the GC won't collect anything until you enable it back (or if the program is running out of memory).
- You can mark a function as @nogc, and then the compiler will prevent you from allocating anything that could trigger GC allocation.
There is some level of support for @nogc in the language and few libraries to help, the issue is more in the standard library which relies a lot on the GC.