Re: Destructor nonsense on dlang.org

2012-05-24 Thread Thor
On Thursday, 24 May 2012 at 12:38:45 UTC, Alex Rønne Petersen 
wrote:

On 24-05-2012 14:33, Thor wrote:
On Thursday, 24 May 2012 at 12:21:02 UTC, Alex Rønne Petersen 
wrote:

Hi,

http://dlang.org/class.html#Destructor

"The garbage collector is not guaranteed to run the 
destructor for all

unreferenced objects."

What the *hell*? So resources are allowed to arbitrarily leak 
and the

programmer has to actually expect this to happen?

I really, really hope that this is a documentation error or 
early

design decision that has since been rectified but with lack of
documentation updates.


use "clear", or "scope (exit)" or "structs" or scoped!... etc.


I know.



There could always be a false reference... so you cannot 
depend on

automatically releasing resources in a class destructor.



False pointers have nothing to do with it. The GC should free 
and finalize all objects on shutdown, meaning the finalizer 
runs *sooner or later*. If this is the case (which I do believe 
it is), then the docs are very wrong.


__gshared uint my_false_ptr;

even if we are shutting down, the static references doesn't 
disappear... or did I miss something?




Re: Destructor nonsense on dlang.org

2012-05-24 Thread Thor
On Thursday, 24 May 2012 at 12:21:02 UTC, Alex Rønne Petersen 
wrote:

Hi,

http://dlang.org/class.html#Destructor

"The garbage collector is not guaranteed to run the destructor 
for all unreferenced objects."


What the *hell*? So resources are allowed to arbitrarily leak 
and the programmer has to actually expect this to happen?


I really, really hope that this is a documentation error or 
early design decision that has since been rectified but with 
lack of documentation updates.


use "clear", or "scope (exit)" or "structs" or scoped!... etc.

There could always be a false reference... so you cannot depend 
on automatically releasing resources in a class destructor.