That's why having no auto-destructors is a dead-end. This is the greatest mistake of such languages like Zig or Odin.
That's why having no auto-destructors is a dead-end. This is the greatest mistake of such languages like Zig or Odin.
Have a boxed object have implemented drop, then when the box leaves some scope the Box will clean up it's stuff (drop implementation if there is any) and deallocate it's memory using the allocator (which the arena will treat as noop).
It's like view span objects in rust. The compiler knowns that a span is logically connected to the parent object and don't allow destroying it when such span exists.
This is not fucking rocket science
> That's why an integrated language mechanism preventing such leaks is much better.
No categorical difference, except one is opt-in. You can even design your static analyzer so it analyses the code of dependencies that haven't opted in.
Anyways: its possible, I am building it as a very side project.
github.com/ityonemo/clr