I will modify that by saying that if there are just a few parameters to a function, positional parameters will work fine, but if there's a chance that some of the parameters might be optional, a hashref of named parameters is the way to go.

Then I think we are broadly in agreement. Then only areas left for arg negotiation are:

  1. How many parameters there need to be before using named parameters make sense.

    I'd set that to be: more than 4.

  2. The rarity with which the need arises (for non-constructors).

    On the basis of my not so exhaustive attempts to find counter examples, I'd say that the times when it's required purely because of the shear numbers of parameters, is really quite surprisingly rare.

    And, the occasions when it's needed to allow the ommision of placeholder undefs, is rarer still. Try as hard as I might, I find pretty impossible to come up with even a hypothetical good example of where there is no natural ordering that would allow logically optional parameters to be placed after all mandatory and more frequently required optional parameters.

    You need the situation where func( mandatory1, mandatory2, optional1, optional2 ) optional2 is logical when optional1 is not required, and optional1 is required when optional2 is not. I haven't found an example of that outside of conflations like select.


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.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

In reply to Re^8: When every microsecond counts: Parsing subroutine parameters by BrowserUk
in thread When every microsecond counts: Parsing subroutine parameters by snowhare

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.