GC only exist if you call ``new MyThing``
Just use your allocators with malloc/free, that is what i do (you do the same in zig, allocators)
if you want to enforce no GC use in your APIs, there is the @nogc attribute you can use
GC only exist if you call ``new MyThing``
Just use your allocators with malloc/free, that is what i do (you do the same in zig, allocators)
if you want to enforce no GC use in your APIs, there is the @nogc attribute you can use
If you do that, is it RAII like C++/Rust? Objects get destructed at end of scope, and members get destructed recursively? Or do you have to manually call `free()` on everything? (which, granted, is significantly easier in languages with `defer` mechanisms)
We really need to get actual reference counting into the language to cover classes properly as well.
It has been on my todo list to write a DIP for this for a while now. ~rikki.
scope obj = new Object;
...
// destroyed at end of scope scope(exit):
scope(failure):
scope(success):
https://tour.dlang.org/tour/en/gems/scope-guardsYou can do RAII with D too, it's your choice, based on your use case