If your Zig code has a for loop in a deinit method, you're using computers wrong.
If your C++ destructor is doing O(N) work thanks to RAII, you are using C++ correctly, but you are still using computers wrong.
Discussion
If your Zig code has a for loop in a deinit method, you're using computers wrong.
If your C++ destructor is doing O(N) work thanks to RAII, you are using C++ correctly, but you are still using computers wrong.
@andrewrk RAII is optional in C++, zig doesn't even give you the option. And as others have posted in the thread, not every resource fits nicely in an arena world view.
@andrewrk I spent a few minutes grepping and skimming Zig's standard library, and there are so many cases with O(n) deinit that you must be trolling. There's a useful and valid version of your heuristic statement. E.g. a single munmap in the wrong place can be a huge problem, and that's a case where the O(n) loop is in the kernel and the constant factor is excellent (inversely proportional to the page size).
@andrewrk I don't get it: an array of file handles, or VkImage has to ne freed sequentially. If the API has array version of these it's nice to use them, but sometimes they just don't exists.
@andrewrk What do you recommend instead?