in reply to On Foreach Loops and Maintainability
"Capture regularities in code, irregularities in data", is the koan of the senior programmer. You've bucked that for a microoptimization.
But yes, I understand your maintenance concern. Suppose besides "arg1".."arg5" (which is another way you could have written that and didn't, which made me wonder), you eventually might have had "arg19" and "gee37". You could have written the original loop as:
And then the maintenance person can add:for (map("arg$_", 1..5)) { .. }
That'd probably be the most flexible, and the most clear.for (map("arg$_", 1..5, 19), "gee37") { .. }
-- Randal L. Schwartz, Perl hacker
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: •Re: On Foreach Loops and Maintainability
by dws (Chancellor) on Oct 11, 2002 at 19:15 UTC | |
|
Re^2: On Foreach Loops and Maintainability
by Aristotle (Chancellor) on Oct 11, 2002 at 17:53 UTC | |
by BrowserUk (Patriarch) on Oct 11, 2002 at 21:11 UTC | |
by Aristotle (Chancellor) on Oct 11, 2002 at 21:25 UTC | |
|
Re: •Re: On Foreach Loops and Maintainability
by jordanh (Chaplain) on Oct 12, 2002 at 13:44 UTC |