So structured programming is great—that is, until you have to exit from a set of deeply nested while loops. That’s when pure structured programming leads to pathologically convoluted logic because you have to litter your program with Boolean variables and conditionals trying to achieve the flow of control you need. This is when being a little “impure” and allowing the use of unstructured flow-control elements (including the infamous goto statement) is useful.

That's from Windows PowerShell in Action, 2nd edition, page 213. It's written by the guy who made PowerShell.

So many kneejerk style rules in the world, and the goto proscription is one of the ones I don't quite get. Don't be "pathologically convoluted" and "litter". Use goto when it's appropriate, and this is the use-case where you're asking for goto by name.

Labels: ,