Oh, BTW, just an additional quote from the Camel Book

I've no idea when that edition was revised; but if it was any time in the last 8 or so years, the revision was lacking.

Neither map nor grep "throw away their return values" when used in a void or scalar context; they simply do not produce that list.

I don't recall which version this was changed for; but it has been so for long enough that anyone leveling charges of "the inefficiency of map in a void context" can only be be cargo-culted repetition of something you've heard or read; not based upon actual experience.

Ie. Don't level a charge until you've tested it for yourself; rather than just parroting what you've heard or read others say.

And I upvoted your post despite a couple of things I don't like to much.

Don't! If you don't like what I say, don't upvote.

Now to those things you apparently didn't like:

And I was only trying to offer a possible reason why the OP asked the question in the first place.

Do you think that your guess as to his reasoning is likely to be any more definitive than my guess?

Yeah, I am more limited than you, sorry about that.

If you set out to be offended; you likely will be; but twisting my words to achieve that happy state is less rhetoric, more ....

I didn't say you were limited; I said your expectations were. And the latter is in no way a personal attack; just a statement of fact based upon your own expression of those expectations.

You expect to see map used to produce a new list from a list. This may be because you've come from a background (some other language; possibly a functional one) where that is the only way their (equivalent of) map can be used. Maybe because that is what you've read that it does. Or maybe it just the only way you've ever used it. None of these is an insult. None of these is a personal attack.

Perl's implementation of many widely used constructs is more flexible than their equivalents in other languages. That is in big part what makes Perl so useful and effective.

In this case, map embraces rather than decries the ability to modify the iterated list in place -- what you called a "side-effect" -- through the use of aliasing of the origin of the list. That allows Perl to achieve efficiencies that would be difficult (Haskell's unsafe* functions) or impossible (Clean/Miranda/Erlang) in other languages.

Labeling others' arguments does not make the label true. Besides, this is just rhetorics, falling short of a proper intellectual argument.

Dealt with above, but to reiterate.

Performance:

[0] Perl> cmpthese -3,{a=>q[@a = map $_*1, @a],b=>q[map $_*=1, @a],c=> +q[$_*=1 for @a] };; Rate a c b a 2.88/s -- -67% -67% c 8.64/s 200% -- -2% b 8.86/s 208% 3% --

If you repeat an idea without having tested it for yourself -- that's cargo-cult.

When the label applied is correct; that is perfectly good "intellectual argument". It's a fact.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re^5: Write code diferently by BrowserUk
in thread Write code diferently by madM

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.