Tan Kwee Heong wrote:
Hi,
I wish to reconcile the information provided from Scott Meyer's More Effective C++ Item 15, with that of Peter Dimov. Could someone post some URLs/referencess of Peter's comments, for my benefit?
Thanks,
"Vladimir Prus"
wrote in message news:d9dopb$3tg$1@sea.gmane.org... Thomas Costa wrote:
1. As Peter Dimov said (IIRC), exceptions are just non-local goto. In this case, non-local goto is fine.
<disclaimer> I didn't see Peter's comments. </disclaimer> When you execute a goto, you still have to unwind any enclosing blocks in your function. If you jump out of a (nested) block, the compiler destructs any objects which are local to those blocks. In this sense, gotos and exceptions are similar. Scott Meyer estimates that returning from a function via an exception could be ~1000x slower than a normal return. However, exiting a block via a goto is probably only marginally slower than a normal exit, since the block still has to be unwound anyway (clean up stack/call destructors) even in a normal exit. PJ