3 ms·
It would. (In fact, you might be able to do this today with runtime.SetFinalizer.) You do have to be careful to avoid bringing back the objects that your final
by pcwalton 15y ago
It would. (In fact, you might be able to do this today with runtime.SetFinalizer.)
You do have to be careful to avoid bringing back the objects that your finalizer references from the grave. If you do that in Go and create cycles, it leaks (which isn't unique to Go, many other languages do this). You need a sophisticated GC (like Java's) or a type system that's aware of the heap/stack distinction of objects (like Rust's) to mitigate that.