On Sunday, 21 May 2017 at 23:59:08 UTC, Guillaume Piolat wrote:
On Sunday, 21 May 2017 at 12:48:10 UTC, Adam D. Ruppe wrote:
Any struct should be able to have its destructor called
Does this rule also applies to class objects?
Yes. If your destructor does modify the state, you should expect
it to be called and have the state ready for it.
When you're using the GC, destructors *may* not be called under
certain conditions:
http://dlang.org/spec/class.html#destructors
But there's no stopping you from destructing manually (via
destroy() call), or by allocating classes manually via malloc or
on the stack.