1. Where is the line, for you, between "need named arguments" and "don't need named arguments" ?

Well, for one thing I like to keep the calling convention for all methods or subroutines in a module consistent.

Sometimes it makes sense to follow the calling styles of similar modules, especially if the module is designed as an alternative.

That said, I prefer using named arguments but sometimes use both, if there's a small number of arguments but many optional "options" to pass to a routine:

$obj->method( $first, $last, \%options );
2. What is your favorite way of doing it ? I like to name arguments in Tk's style (-arg) - because I find CAPPED_NAMES bulky, and non_capped_names can clash with symbols. I also use the ending @_ trick to provide default values inside the sub.

I really dislike the Tk calling style with the beginning hyphen. CAPPED_NAMES are irritating, and I prefer to use them for constants and names of constant hash keys in objects. I don't find there to be a problem with non_capped_names clashing with symbols: if there's a clash, consider using different names.


In reply to Re: named arguments by rrwo
in thread named arguments by spurperl

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.