Friday, March 24, 2006

C++ Exceptions: Continuance

In designing a language that supports exception handling, one must consider the aspect of continuance: where does execution resume after the exception has been raised?

I recently came upon an online conversation of Bjarne Stroustrup, in which he discusses why resumption directly after the statement that raised the exception wasn't implemented.

Basically, someone resuming from an exception handler can never be sure that the code after the point of throw was written to deal with the excecution just continuing as if nothing had happened. An exception handler cannot know how much context to "get right" before resuming. To get such code right, the writer of the throw and the writer of the catch need intimate knowledge of each others code and context. This creates a complicated mutual dependency that wherever it has been allowed has led to serious maintenance problems.
This is probably of very little interest to many people, but I find it rather facinating to see why certain decisions were made.

No comments: