Is "delete" really going away?

Simen Kjaeraas simen.kjaras at gmail.com
Sun Jul 29 06:24:06 PDT 2012


On Sun, 29 Jul 2012 15:03:09 +0200, Minas Mina  
<minas_mina1990 at hotmail.co.uk> wrote:

> Having a destructor and that you know when is going to be called is VERY  
> useful!
> So by removing the "delete" keyword, what happens? We won't have a way  
> to destroy objects in a predictable way anymore? (I'm not talking about  
> structs in any way).

You should instead use destroy(instance). It will call the object's
destructor and clear its vtable. If you need to release the memory too,
you should probably use malloc and free, and std.conv.emplace.

If you have a GC allocated object and want to reclaim the memory,
core.memory.GC.free should do that. But if this is something you need to
do, you've probably done something wrong somewhere.

Oh, apparently, destroy() is called clear in 2.059. It's being renamed
in the next version.

-- 
Simen


More information about the Digitalmars-d-learn mailing list