On Tuesday, 27 June 2017 at 15:24:00 UTC, Steven Schveighoffer
wrote:
On 6/27/17 9:25 AM, Guillaume Piolat wrote:
On Tuesday, 27 June 2017 at 13:11:10 UTC, Steven Schveighoffer
wrote:
But I would use a close method, and not destroy(obj). The
reason is because often times, you have wrapper types around
your socket type, and just one extra level of indirection
means the destructor cannot be used to clean up the socket
(you are not allowed to access GC-allocated resources in a
destructor).
All destructor restrictions do not apply when it's not called
by the GC.
There really are two categories of destructors: called by the
GC and called deterministically. Their usage should not
overlap.
Yes, Tango solved this by having a separate "finalize()"
method. I wish we had something like this.
Well, technically speaking the `~this` for D classes *is* a
finalizer that you may optionally manually call (e.g. via
destroy).
It would be nice, though, to change class `~this` into a
destructor and move the finalization into an extra method like
`finalize`. Write a DIP?