Re:Async destructors, async genericity and completion futures
by lilyball on Wednesday June 01, 2022 @08:20PM
(#31589829)
Yes, but you'd have to generate that dummy value upon creating the real value, and then pass it along with the real value so it's available to the spot that needs to consume it. This would ultimately end up being just a much more awkward way of having the real value just track a boolean internally for this and slapping Option around any non-trivial return value from the method.
Re:Async destructors, async genericity and completion futures
by Animats on Thursday June 02, 2022 @01:57AM
(#31591849)
> There is no way to statically guarantee that the method isn’t called twice, that’s up to the user.
That sounds like "re-animation", where a destructor leaks something to the outside that keeps the object from being destructed. That was in Microsoft Managed C++, and it was similarly awful.
If all you want to do is clean up something on deletion, how about passing the thing that needs cleanup to a channel, to be handled by another task?
Couldn't this be solved by giving the user a dummy object that isn't Clone and that the method takes ownership of?