in reply to Re: Re: Re: Re: Think for yourself.
in thread is the use of map in a void context deprecated ?
I think that you emphasized my point. As I said, To me both grep and map make me start looking for where the return is going because the return is likely to be the point of the operation. Your code example is:
I glance at this, and indeed the return is the point of the operation. Just the words, "minutes", "map", "60" and "seconds" makes it blindingly obvious.my @minutes = map { $_ / 60 } @seconds;
However it is even more obvious because your code fits a visual pattern that I expect to see. Even a trivial code example with map or grep used for side-effects forces me to think. Compare
vsmap {$_ /= 60 } @times;
Yeah, both are bad style. But of them, the latter is significantly easier for me to read, and not just because of length.$_ /= 60 for @times;
On an unrelated stylistic note, if the contents of a complex mapping become complex, rather than go to a foreach loop, I am inclined to write a function for the body of the map, name it well, and insert it into the map. This emphasizes that the operation is not simple, indicates what it is, and makes it clear that the point of the code is to return something. I find this clearer, YMMV.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re:x6 Think for yourself.
by gwadej (Chaplain) on Nov 04, 2003 at 03:52 UTC | |
by tilly (Archbishop) on Nov 04, 2003 at 06:24 UTC | |
Re: Re: Re: Re: Re: Re: Think for yourself.
by BrowserUk (Patriarch) on Oct 30, 2003 at 20:15 UTC | |
by tilly (Archbishop) on Oct 30, 2003 at 22:01 UTC | |
by BrowserUk (Patriarch) on Oct 30, 2003 at 22:38 UTC | |
by tilly (Archbishop) on Oct 30, 2003 at 23:04 UTC |
In Section
Seekers of Perl Wisdom