|Just another Perl shrine|
Comment onby gods
|on Feb 11, 2000 at 00:06 UTC||Need Help??|
I guess I've just realized that we are agreeing more than arguing.
I had a major realization about the list operations in Perl a (relatively) short time ago, and I've been trying to explain it to others (and myself) ever since. I found that some of the problems I was working on simplified drastically when I used the list operators on lists of homogeneous data.
I think you've helped me to understand that a lot of what I've been trying to say really boils down to another application of the Principle of Least Surprise. The places where I find the list operators to be the most useful are where they can reduce surprise to some extent.
My example that you quoted above is a good use of map because it does what the reader expects because it follows the right visual pattern.
The "bad" example you gave above gives the wrong kind of visual feedback and, therefore, causes more surprise. This is also code that is more likely to be corrected incorrectly, because the one who comes after may think they know what it is doing at a glance and be wrong.
My thanks. You've given me quite a bit to ponder.