Bug 9137 – A function that equals to "out of scope" action for manual lifetime management

Status
RESOLVED
Resolution
WONTFIX
Severity
enhancement
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-12-10T11:17:00Z
Last change time
2017-07-07T17:11:38Z
Assigned to
nobody
Creator
verylonglogin.reg

Comments

Comment #0 by verylonglogin.reg — 2012-12-10T11:17:49Z
We already have `emplace` to create an object but there is not function to destroy the object. Yes, we have `destroy` but it is "to reclaim non-memory resources without compromising memory safety" (as Andrei said). So I'd like to have a `destuct` function destroying its argument just like as if it goes out of scope and, optionally, resetting object memory to it's initial state. The function is implemented here: https://github.com/D-Programming-Language/phobos/pull/929
Comment #1 by verylonglogin.reg — 2012-12-10T11:49:05Z
Also note, as we have no such function currently one can easily consider that `destroy` is such function and use it thinking it works this way. And it is very dangerous, see Issue 9139 for details.
Comment #2 by dlang-bugzilla — 2017-07-07T17:11:38Z