Why will the delete keyword be removed?

Vladimir Panteleev vladimir at thecybershadow.net
Thu Jul 15 01:07:18 PDT 2010


On Thu, 15 Jul 2010 11:03:07 +0300, Rory McGuire <rmcguire at neonova.co.za>  
wrote:

> On Thu, 15 Jul 2010 09:08:24 +0200, Vladimir Panteleev  
> <vladimir at thecybershadow.net> wrote:
>
>> On Thu, 15 Jul 2010 04:00:49 +0300, Jonathan M Davis  
>> <jmdavisprog at gmail.com> wrote:
>>
>>> Ideally, you'd want things to blow up when such an object was used,  
>>> with
>>> it clearly indicating that it was because you used an object which  
>>> isn't
>>> supposed to exist anymore.
>>
>> I suggested this as well, by stomping on the object's memory in debug  
>> builds. Andrei has different goals.
>>
>
> Surely you can't just stomp on the memory?
> You'd have to keep it allocated so nothing else ends up being allocated  
> there, and you get weird inconsistent errors, debug mode or not.

If you want to keep the stomped-on object allocated to prevent that, there  
is no problem doing it - just don't do immediate deallocation in debug  
builds, and let the GC collect the object when it sees no references.  
However, if you want to catch dangling pointer bugs with absolute  
certainty, the best solution is to use tools such as Valgrind, which keep  
track of which memory is safe to read, etc.

-- 
Best regards,
  Vladimir                            mailto:vladimir at thecybershadow.net


More information about the Digitalmars-d mailing list