Deterministic resource freeing - delete deprecation (again)

Steven Schveighoffer schveiguy at yahoo.com
Wed Apr 27 10:13:23 PDT 2011


On Wed, 27 Apr 2011 12:26:38 -0400, Jacob Carlborg <doob at me.com> wrote:

> On 2011-04-27 17:41, Alexander wrote:
>> On 27.04.2011 17:23, Steven Schveighoffer wrote:
>>
>>> 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.
>>
>>    Not really. Dispose() may be called more than once, there is no  
>> guarantee that resources are still allocated.
>
> What I think Steven meant in this case is that when calling dispose, in  
> Tango, any object will still be valid, i.e. the garbage collector hasn't  
> collected it yet.

Yes, that is exactly right.  I meant literally memory, not all resources.

>>> The name choice is no longer up for debate.  It's already set in  
>>> print, and in the language.
>>
>>    Well, it took me some time to find it out "in print" and "in the  
>> language", given that everywhere on site no single reference to it, and  
>> in most recent D2 it doesn't work correctly.

There is a recently filed report on the lack of documentation.

>>
>>    Not to mention that it conflicts with std.container and std.array,  
>> where semantics of clear() is quite different (removes elements) - are  
>> those will be changed too?
>>

clear is not a keyword, it is possible to name a member clear, and also  
have a clear global function.

-Steve


More information about the Digitalmars-d mailing list