You're making the definition of the function more complex. It no longer does one single thing; it now does different things when called in different contexts.

If you hate the idea of people writing reduce expressions, and are afraid this would encourage it, I'm afraid that cow is already out of the barn. It's a fundamental function for array processing; a built-in one in many languages.

That cow is called "LISP", and it's been the toy of academics, and a total commerical failure, for approximately the last fourty years. The fundamentals of functional programming haven't changed since then. It's still too abstract, too pointless, and too far removed from the actual imperatives of daily life (there's a reason we think in an imperative style -- it's how we live).

Don't get me started on map() -- I've seen more twisted code written using map() idioms than any other. In general, when I see a map() statement, I have to mentally start refactoring, because odds are, the code won't work.

90% of the time, I'm right. People who use map() tend to be too clever for their own code, and write 80% solutions that have to be re-written from scratch to actually solve the real problem at hand. Maybe you're smart enough to pull off a functional language, but I've been bitten by too many people who weren't to be impressed.

So, if you want to program in a functional language, do so. But don't ruin perl any more than it is already -- God knows how many messes I've had to clean up thanks to overzelous use of map() statements! :-( I shudder to think what life will be like if reduce() (by any name) becomes part of the perl core! :-(
--
Ytrew


In reply to Re^3: RFC: Should join subsume reduce? by Anonymous Monk
in thread RFC: Should join subsume reduce? by Roy Johnson

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.