[Issue 9433] Deprecate delete

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jan 31 08:57:28 PST 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9433



--- Comment #9 from rswhite4 at googlemail.com 2013-01-31 08:57:26 PST ---
> Except that new allocates GC memory, which is supposed to be managed by the GC.
> If you want to be managing memory yourself, you should use the tools intended
> for doing so - and that's not new or the GC. The language designers decided
> quite some time ago that delete was going to be deprecated. They just haven't
> gotten around to doing so. But it's definitely going to go. In fact, if they
> were to start over, they probably wouldn't have even had new (rather they would
> have had a library function which did the same thing), but they wouldn't have
> delete regardless. It was deemed too unsafe, and having it as a keyword makes
> it too obvious to use. At least with core.memory, it's much more obvious that
> what you're doing is dangerous and likely unwise.

But GC.free does not calls any DTors. That is the problem. Therefore we need
something like "destruct".

@FG:
> Nice, holds steady at 40MB, but there's a catch. When you remove the line
> "destruct(a);" and rely on the GC to remove unnecessary A instances, the
> program will crash, because GC.free cannot be called during a collection. So I
> think it's a bit too dangerous.
That's true, but it's the same if you use delete. It's an alternative. :)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list