in reply to Re: Efficient Looping Constructs
in thread Efficient Looping Constructs
To me, LOW and HIGH are very clearly stated in the foreach. In the for-loop, there are more characters involved. In addition, those characters are semi-colons. This is the only place in C (or Perl) where the semi-colon does not indicate the end of a thought. It, instead, indicates the end of a sub-thought. You have a rule, then you have an exception to the rule that's used everywhere! I understand why they did it, and I understand the syntactic reasons for it, too. But, I do not think of for-loops as three separate statements within a block construct. All other block constructs are one statement-one thought. Why should for be any different?!?my $sum = 0; for (my $i = 0; $i <= $num; $i++) { $sum += $i; } ##### my $sum = 0; foreach my $i (0 .. $num) { $sum += $i; }
------
We are the carpenters and bricklayers of the Information Age.
Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Efficient Looping Constructs
by danger (Priest) on Oct 02, 2001 at 01:26 UTC | |
by dragonchild (Archbishop) on Oct 02, 2001 at 19:42 UTC | |
by danger (Priest) on Oct 03, 2001 at 00:36 UTC | |
by dragonchild (Archbishop) on Oct 03, 2001 at 00:57 UTC |