www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18505] New: delete deprecation message is misleading

https://issues.dlang.org/show_bug.cgi?id=18505

          Issue ID: 18505
           Summary: delete deprecation message is misleading
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: diagnostic
          Severity: minor
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: schveiguy yahoo.com

Currently, the dprecation message for delete says:

Deprecation: The delete keyword has been deprecated.  Use object.destroy()
instead.

However, this is not complete. In order to fully replace the mechanism of
delete, you must call GC.free on the pointer.

In many cases, people have used delete and expect the memory to be freed.
Telling them that all they have to do is use destroy is not going to satisfy.

I suggest (similar to Bearophile's suggestion in issue 9433): 

use object.destroy (and optionally core.memory.GC.free) instead.

There is also this new function (unreleased as of 2.079, but in druntime
already): https://dlang.org/phobos-prerelease/core_memory.html#.__delete

--
Feb 23 2018