Allocating structs with new?

Justin Johansson no at spam.com
Mon Jul 12 06:07:48 PDT 2010


bearophile wrote:
> Justin Johansson:
>> With care?  That doesn't say very much except for possibly an
>> unintended suggestion that the OP is not trying to use care.
>> He is posting because he does care.
> 
> I probably meant something different.
> What I meant is just that one of the main purposes of a GC is to free programmers to manually release memory, this makes many other things simpler. If you keep a way to manually delete an object in a GC-based language then the programmer has to use care, to avoid memory leaks, etc.
> 
> In Python there you can do:
> del x
> 
> but it doesn't deallocate the object x, it just decreases by one the reference counts of x (and removes the corresponding name in the current scope), this can lead to the deallocation of x, but it can also happen later. There is no direct command to directly delete an object. So you need less care.
> 
> Bye,
> bearophile

I probably meant something different too and also remiss of me
to leave out a few smilies. :-)

"has to use care, to avoid memory leaks, etc."  Yes and presumably
"etc" includes not attempting to delete anything more than once.

Cheers
Justin


More information about the Digitalmars-d mailing list