-- Tony Bowden <[EMAIL PROTECTED]>

On Sat, Nov 02, 2002 at 12:13:19PM -0000, Jeff wrote:
It sounds like you're saying that you should only use a subset of Perl
as some programmers may not understand the other parts of it?

That is what I'm saying.  I'm aware that this is a controversial
opinion in the Perl world.  However, I think it's reasonable to
know your audience and write for them.

Have to agree 100% with Perrin - in my experience, refactoring for
performance is often used as an excuse for 'rewrite in my style',
I'm not sure anyone has actually posited using map for performance, but
in most cases that would indeed be a pretty stupid reason to use it.
See the Schwartzian Transform for an excellent example of
where you would use map for performance. Main advantage is
getting perl to manage the list space. If I find myself
writing for(blah){ push @foo, something } it can usually be
done more simply via @foo = map { something } ( blah ). If
you end up making large lists, especially in loops, then map
can be a speedup. It is also faster if you have to flatten
out strucures frequently (vs iterating over keys %foo and
assigning things one at a time).

map can also be convienent in allowing for lexicals that
are assigned when they are built, similarly grep:

	if( my @process_this = grep {-s > $cutoff} @filz )
	{
		deal with @process_this here, know it won't
		outlive the braces.
	}

Defining the lexicals in a scope where the don't outlive
their purose can be a big help in maintainability.

--
Steven Lembark                               2930 W. Palmer
Workhorse Computing                       Chicago, IL 60647
                                           +1 800 762 1582

Reply via email to