Preface: This was asked in a comment in the following FAQ, and I think it deserves its own topic: How big is the performance impact for error handling for a procedure/function call in case no exception does occur - compared to omitting the exception handler? In other words: If I don't really expect any possible exception but would add a general exception handler like the following, do I have to pay a noticeable "amount of runtime performance" for this means of defensive programming? Or does it cope, say, with C++'s goal of "You don't pay for what you don't need"? procedure foo( ...parameters... ) begin ...code... exception when ...specific-exception... then ...handle-specific-exception... when others then -- log general error resignal; end; |
To cite Elmi Eflov from the other FAQ:
and Mark added:
As a consequence, there is no performance reason not to add a general exception handler:) |
@Breck, @Elmi, @Mark: You're invited to answer this here again:)