Consider what happens if another function in try block also happens to throw an integer. That throw will trigger your goto replacement instead of up to the next matching catch block higher up the stack.

Anyway, if you are going to use goto-like behavior, use a goto! At least you'll be clear in your intentions!

The problem most people have with goto is that the logic for a goto is disconnected from the logic for a loop. For while, do-while, and for loops, the logic is intimately connected to the loop (specifically where the loop is defined). This connection is important because it makes code more maintainable. Without the connection, it is very easy to make spaghetti code.

My rule of thumb: The only time one should use goto is when writing time-critical code and profiling shows that it is not possible without gotos. (If your time-critical code will improve by use of goto's, it is likely already going to have some other uncommon constructs that will be difficult to maintain. And yes, I have come across these cases.)

- Kevin