Allocating structs with new?

bearophile bearophileHUGS at lycos.com
Sun Jul 11 11:57:23 PDT 2010


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


More information about the Digitalmars-d mailing list