On 4/30/14, 7:20 PM, Steven Schveighoffer wrote:
On Wed, 30 Apr 2014 21:51:38 -0400, Andrei Alexandrescu
<seewebsiteforem...@erdani.org> wrote:

On 4/30/14, 6:04 PM, Steven Schveighoffer wrote:
destructors are for cleaning up non-GC resources. File handles, malloc'd
memory, etc. I don't see why these need to be eliminated.

Virtually all GCs are known to be horrible at managing scarce
resources (including memory itself).

The destructor can be a crutch, but it's not good to leave open
resources when the user of your code has not cleaned them up manually.

Sounds like defensive programming to me.

I can see no reason to disallow destruction from cleaning up resources
that nobody else has managed to clean up.

Make memory management faster and better for everyone. I'm not saying it's reason enough, but it's a reason.

The largest problem with D destructors comes from trying to clean up D
objects in destructors of structs, that you never expected to be done
via the GC.

Cleaning up files and malloc'd memory is not an issue.

Not getting this...


Andrei

Reply via email to