See the Contents Page for this series of articles
It’s a widespread belief that
finally blocks “always” execute, sometimes with hilarious implications.
Last time I reasoned logically that in order for our code to have predictable behaviour, we should stop it running when it becomes clear we don’t understand the state the program is in. As
finally blocks are filled with little chunks of our code, it stands to reason that they shouldn’t execute when things get Ugly.
Now I’m going to discuss the specifics of what can go wrong if they are always forced to execute, as they are in a couple of popular languages, C++ and Java (and also by default in CLR-based languages).
Yes, this is a long one, but I’m going to try to start a few language wars, so it should be fun!