Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
works just fine. There are several other options as well. First there is the continue that you mentioned: and then (depending on what you do in the if statement) there is reversing the order of your operations: You can have the chain of ifs be replaced by a function call that returns from multiple points: And so on. I have, in fact, used every one of these solutions except the goto one, and I prefer all of them to the goto solution. Why? Because I find each of them clearer, they allow me to see program flow in terms of following blocks. The goto forces me to see an element of program flow which is not some form of block. I don't like that. Furthermore, no matter how clearly the goto solution's intention may be, its use opens up the possibility of traps like this: By contrast anything only relying on return and loop control statements can be much more easily verified correct based on local examination. (OK, in this case your goto construct is verifiably correct without looking at outside code. But it will take more time for most people to figure out why the one is verifiably OK while the other is demonstrably bad than it will to figure out my alternate solution.) Again, this is not something I would use a goto for.
UPDATE In reply to Re (tilly) 6: Fear of Large Languages (was: "Would you use goto")
by tilly
|
|