On Monday, 1 April 2013 at 20:58:26 UTC, Walter Bright wrote:
On 4/1/2013 4:08 AM, Lars T. Kyllingstad wrote:
It's time to clean up this mess.
As for why finally blocks are not executed for Error
exceptions, the idea is to minimize cases where the original
error would now cause an abort during the unwinding process.
Catching an Error is useful for things like:
1. throw the whole plugin away and restart it
2. produce a log of what happened before aborting
3. engage the backup before aborting
4. alert the operator that the system has failed and why before
aborting
Unwinding is not necessary for these, and can even get in the
way by causing other failures and aborting the program by
attempting cleanups when the code is in an invalid state.
I think that view is reasonable, but then I don't understand the
reason to have Error in the first place! Why not just call some
kind of abort() function, and provide the ability to hook into it?
BTW, I actually went to quite a lot of trouble to make stack
unwinding work correctly for Errors on Windows. It really wasn't
easy.