Deterministic resource freeing - delete deprecation (again)

Steven Schveighoffer schveiguy at yahoo.com
Wed Apr 27 08:23:04 PDT 2011


On Wed, 27 Apr 2011 11:08:23 -0400, Alexander <aldem+dmars at nk7.net> wrote:

> On 27.04.2011 16:48, Steven Schveighoffer wrote:
>
>> basically, dispose cleans up resources *knowing* that all its  
>> references are still valid.
>
>   Right, but cleaning of resources doesn't mean that object will be  
> destructed - it can be reused afterwards (connection reestablished, file  
> reopened etc).

I don't think reuse is a requirement of dispose.  It might be that those  
resources are only allocated on construction, which would require you to  
re-construct the object.  I think the only difference between the  
destructor (finalizer) and dispose is that dispose is guaranteed that all  
the memory is still allocated, whereas the finalizer is not given that  
guarantee.

>> The deallocation of object memory is a separate thing (outside dispose  
>> or the destructor).
>
>   That's why I think that clear() is bad name choice, when it leads to  
> destruction :)

The name choice is no longer up for debate.  It's already set in print,  
and in the language.

-Steve


More information about the Digitalmars-d mailing list