SPUG: English-speak about Perl-speak "for" loops
Jacinta Richardson
jarich at perltraining.com.au
Sun Sep 17 18:34:22 PDT 2006
Michael R. Wolf wrote:
> I've started seeing more code that uses 'for' for both kinds of loops.
>
> for(init; entry-condition; iteration) { block }
> for loop-variable (list) { block }
>
> I know it doesn't confuse the compiler to use 'for' or 'foreach' in either
> case, but it sure does make it harder to speak about. For that reason, I
> always used to write (and speak) "for" to refer to the C-style 'for' loop
> and "foreach" to refer to the other one.
>
> If you use "for" for both Perl-speak styles, how do you English-speak about
> it to avoid ambiguity?
I almost always use "foreach" instead of "for" when I could be lazy and leave
off the four extra chars. However I speak it as:
for my $element (@list) {
for/foreach my element in @list do ....
for (my $i = 0; $i < @list; ++$i) {
for my i is zero, i is less than @list, pre-increment i; do ....
I assume that the person I'm talking to knows enough syntax to guess the missing
bits.
All the best,
J
--
("`-''-/").___..--''"`-._ | Jacinta Richardson |
`6_ 6 ) `-. ( ).`-.__.`) | Perl Training Australia |
(_Y_.)' ._ ) `._ `. ``-..-' | +61 3 9354 6001 |
_..`--'_..-_/ /--'_.' ,' | contact at perltraining.com.au |
(il),-'' (li),' ((!.-' | www.perltraining.com.au |
More information about the spug-list
mailing list