TITLE: it'd be nice to have exception resume facilities (Newsgroups: comp.lang.c++, 13 Sep 96) [ This picks up on a discussion about having an exception "resume" facility in C++. -adc ] PROBLEM: grantp@usa.pipeline.com(Pete Grant) Doesn't that sound seductive? I certainly would not complain if we had the same capability in c++. RESPONSE: ark@research.att.com (Andrew Koenig) Yes it does sound seductive. But yielding to seduction is not always good for you -- it depends on the circumstances. In this particular case, one of the key circumstances is that if it is possible to resume after an exception, then every program that throws an exception must be capable of dealing with a resumption attempt. That is, if your code discovers a situation it can't handle, it is no longer possible to admit defeat by throwing an exception; you might get control back anyway, whether you want it or not. For a lot of purposes, it is possible to achieve an effect similar to calling a resumable exception by having your code call a plain ordinary function for fixup action (the address of which might be stored in a pointer somewhere, in the style of set_new_handler). That function could then either return or throw an exception to get out. The advantage of this approach is that the implementation does not have to start unwinding the stack until it is crystal clear that the stack will not be rewound. In the case of an exception that might resume, it is essentially impossible to begin stack unwinding until the exception handler has decided that is not going to resume, and that causes unbelievable implementation headaches. For the implementors in the audience, one of the arguments in the committee discussion went this way: Resumable exceptions require at least as much implementation mechanism as nested functions, because in the presence of resumption, an exception handler must be able to `reach back' in the stack to obtain the activation record of the (statically) surrounding context. But the committee had already discussed, and rejected, a proposal to add nested functions. Therefore, if the committee wishes to allow exceptions to resume, it should first reconsider the decision about nested functions, as it will need that mechanism anyway. Arguments along those lines convinced essentially everyone on the committee, except for the representative of one company who said that his company already had resumable exceptions, and that he was under orders to support it regardless of the strength of the arguments to the contrary.