Destructors are inherently difficult to design and I'm well aware they are 
currently **unusable**. :)

There are mostly 2 different ways to design them: C++ style which assumes the 
compiler cannot do any lifetime analysis but then allows for certain assignment 
optimizations in the spec (and more recently it requires them iirc) and Rust 
style which bases it on top of its superb lifetime analysis. The beginnings of 
a lifetime analysis for Nim is in `compiler/writetracking.nim`. This computes 
"deep immutability" and whether the memory coming from a parameter is escaping. 
Without more source annotations. So ... first we need to get this into 
production ready shape before tackling destructors...

Reply via email to