On 9/11/07, Bob Rogers <[EMAIL PROTECTED]> wrote: > From: "Ben Tilly" <[EMAIL PROTECTED]> > Date: Tue, 11 Sep 2007 14:18:57 -0700 > > On 9/11/07, Palit, Nilanjan <[EMAIL PROTECTED]> wrote: > [...] > > > It is very bad form to use map as a looping construct. > > > > Can you elaborate why it is a bad form: readability, performance, ...? > > Just want to understand the underlying reason. (To me, both the for & > > map inline forms appear to be the same readability & performance wise.) > > Readability is the big difference . . . > > . . . Furthermore you're demanding > more from your readers than you need to. Anyone who speaks English > (or who knows a couple of computer languages) can guess what a for > loop does. But only people who know Perl will understand what map > does. > > Am I reading this right? Are you actually defending the lowest common > denominator of language design? The paragraph above seems tantamount to > saying,
Not exactly. I'm saying that *all else being equal*, make things as simple as possible. If you've ever had the experience of programming in another language for a while, and then having to quickly fix a bug in some old Perl of yours, you'll understand the benefit of this philosophy. > Perl has some nice functional programming features, but don't > use them, because you might confuse people who only know > stupider languages. All else is not equal in that case. :-) That said, know your audience. Using functional techniques in Perl should be a deliberate decision. In many programming groups, I'd never use them because the others couldn't maintain that cde. In other programming groups I'd use them freely. And I say this as one of the people who helped introduce a lot of Perl programmers to some of the functional features of Perl. (See http://www.perlmonks.org/?node_id=34786 for a post that many people cited at one point.) > I agree with most of your points, and think they are sufficient to carry > the argument. This point does not help your case, and would be > counterproductive in situations where "map" would be the better choice. If your audience is capable of handling map, and there is a concrete benefit from using it, then use it. Which advice if followed means that you'll be using map only when you're planning on using the return list. :-) Cheers, Ben _______________________________________________ Boston-pm mailing list [email protected] http://mail.pm.org/mailman/listinfo/boston-pm

