in reply to Re^2: Useful uses of redo?
in thread Useful uses of redo?

There isn't necessarily any reason not to use do { ... }, as long as you realize that a do block isn't 100% like bare blocks. I look at do blocks kind of like immediately executing subroutines minus the parameter list, since do blocks have return values vaguely similar to subs.

If you're concerned about the visual ambiguity of a bare block with a redo inside it, you can always start it off with a label, as in:

LOOP: { # do some stuff redo; }

However, even though while(1) (and even for(;;)) sort of perpetrates a fib, it is still more flexible to use such constructs over the bare block / redo method, because bare blocks don't support continue, occasionally useful with explicit loops.


Dave