vestigial delete in language spec
Alex Rønne Petersen
alex at lycus.org
Thu Nov 1 15:07:48 PDT 2012
On 01-11-2012 22:21, Dan wrote:
> TDPL states
> ------
> However, unlike in C++, clear does not dispose of the object’s
> own memory and there is no delete operator. (D used to have a
> delete operator, but it was deprecated.) You still can free
> memory manually if you really, really know what you’re doing by
> calling the function GC.free() found in the module core.memory.
> ------
> The language spec has this example from the section on Struct
> Postblits:
> ------
> struct S {
> int[] a; // array is privately owned by this instance
> this(this) {
> a = a.dup;
> }
> ~this() {
> delete a;
> }
> }
> ------
>
> Is the delete call, then per TDPL not necessary? Is it harmful or
> harmless?
>
> Also, are there any guidelines for using and interpreting the output of
> valgrind on a D executable?
>
> Thanks
> Dan
The docs are supposed to not use delete. In this particular case, you'd
use core.memory.GC.free(a.ptr); instead.
--
Alex Rønne Petersen
alex at lycus.org
http://lycus.org
More information about the Digitalmars-d-learn
mailing list