I would personally replace it with a redo on a bare block. That bare block would also be a hint to indent the potentially redone section of code, which naturally draws attention to that control structure.
General rule of thumb. Any normal use of goto can be replaced by an entirely equivalent loop control statement, possibly using labels when breaking out of multiple levels of loops. Unless there is a good reason not to, I prefer that approach. | [reply] |
| [reply] |
The problem of declaring a variable in a block I can appreciate as valid.
We disagree though on the code which, when turned into nested loops becomes very deep. That is a code smell that tells me that something should probably be rewritten. Obscuring that problem by using gotos just compounds the problem. I would therefore like to see the ugliness of the structure made as apparent as possible, as a prelude to figuring out whether you can rewrite it.
Perhaps we work on very different things. But I have never once used goto other than the goto &foo; form in anything outside of play code in Perl. And I think it unlikely that I ever will. (Though I would use it in C++.)
You may wish to read Re (tilly) 4: Paradigm Shift - when to use goto for an explanation of where I theoretically would use goto. Note that this is theoretical since I have not personally needed it. (Other than for removing the current stack from from the stack.)
Incidentally I am amused to see goto defended by a fan of a language without goto. :-)
| [reply] [d/l] |