in reply to Re: Re4: Efficient Looping Constructs
in thread Efficient Looping Constructs

After thinking about this for a while, I realized the biggest Perl reason why foreach, in my mind, is more readable than for. It's the fact that so much in Perl is predicated on lists. map, grep, push, etc ... there's so much about lists. Then, all of a sudden, I go from dealing with a list to dealing with the implementation of a list. I don't care about index numbers - I care about the holistic, organic list. :-)

To reply to your node, I have read Code Complete and do remember both sections you refer to.

The indentation study ... it was interesting, but he was using it, in my opinion, more to discuss that indentation systems aren't arbitrary vs. readability issues.

As for the looping mechanisms ... for-loops do package a lot in a single place. That's their benefit and their Achilles' heel. Yes, I do have a beef against for-loops, primarily because they've been abused way too much in C. I remember reading some for-loops where the conditions had more lines than the block itself!

I do use for-loops when they make sense in Perl. I prefer the foreach construct (but will use the word 'for' instead of 'foreach'), primarily because it says only what it needs to say. I'm a fan of minimalist programming - say only what you need to say and no more. for-loops tend to say more than what's needed.

------
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.