in reply to Re: Control Structures
in thread Control Structures
Really? Thats an interesting observation, I always found both forms useful for minimizing noise and making flow control clearer. I find unless in either form (block or modifier) somewhat more inclined to be difficult, but the modifier if, and even unless coupled with loop control statements like next and last to be very useful in enhancing readability.
When I see something like
next if $condition;
it allows me to think "condition is prohibited past this line", i dont have to worry that later on the block ends and !$condition is still possible. For instance in the following code if at a later I point I forget the importance of the next, or possible restructure code so it doesnt fire sometimes something bad could happen after the block and I might not even notice it until debugging. The statement form doesnt allow such complexity so it sort of red-flags itself as being "mess with this and the code below has to be completely reconsidered."
if ($condition) { ... next; } # !$condition stuff can happen here
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Control Structures
by perrin (Chancellor) on May 10, 2005 at 15:08 UTC | |
by dragonchild (Archbishop) on May 10, 2005 at 15:23 UTC | |
by perrin (Chancellor) on May 10, 2005 at 16:26 UTC | |
by merlyn (Sage) on May 10, 2005 at 17:07 UTC | |
by dragonchild (Archbishop) on May 10, 2005 at 17:41 UTC | |
by wazoox (Prior) on May 10, 2005 at 22:09 UTC | |
by perrin (Chancellor) on May 10, 2005 at 18:20 UTC | |
| |
by demerphq (Chancellor) on May 10, 2005 at 15:33 UTC | |
by glwtta (Hermit) on May 12, 2005 at 03:16 UTC | |
by perrin (Chancellor) on May 12, 2005 at 05:03 UTC | |
by glwtta (Hermit) on May 12, 2005 at 05:26 UTC | |
by perrin (Chancellor) on May 12, 2005 at 05:37 UTC |