On Friday, 5 February 2016 at 08:16:05 UTC, Ola Fosheim Grøstad wrote:
If you can test for "uncaught_exceptions" you can implement the equivalent of scope(failure/success) etc within destructors.

Sorry, years of python programming have made me shy of destructors. It just looks a little less "magic" to me if I specify the destruction explicitly after creating the object, using the "scope(exit)" syntax. "scope(success)" and "scope(failure)" have no analogy in destructors as far as I know. Destructors just destroy the object, and doing more than that is risking weird edge conditions.

But again, if you already have your elaborate destructor, you can set "o.fail = true" in a "scope(failure)" statement, and the destructor just has to check this.fail for how it's being destroyed..

Reply via email to