Issue 9137 - A function that equals to "out of scope" action for manual lifetime management
Summary: A function that equals to "out of scope" action for manual lifetime management
Status: RESOLVED WONTFIX
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P2 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-10 11:17 UTC by Denis Shelomovskii
Modified: 2017-07-07 17:11 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Denis Shelomovskii 2012-12-10 11:17:49 UTC
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 Denis Shelomovskii 2012-12-10 11:49:05 UTC
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 Vladimir Panteleev 2017-07-07 17:11:38 UTC
The PR was rejected, closing.

https://github.com/dlang/phobos/pull/929#issuecomment-11167033