[Issue 9433] Deprecate delete

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jan 31 08:45:42 PST 2013


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



--- Comment #7 from Jonathan M Davis <jmdavisProg at gmx.com> 2013-01-31 08:45:41 PST ---
> But you have to admit: if there is "new", there should be "delete" also.
> Because it is the natural opposite.

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.

> Even if it is "unsafe", the possibility to free even GC memory by yourself,
> should be there.

That's what core.memory is for. It's there because D is a systems language, but
it shouldn't be used normally. If you're using the GC for manual memory
management (which is what you're doing if you're telling the GC to free
memory), then you're using it incorrectly. Use malloc and free if you want to
manage memory manually.

-- 
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