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

For me it's less a matter of number than it is about how the arguments will be used. If they'll be used to add to or override someone else's values, then named args are the way to go. This lets me write, for one contrived example,

sub foo { my ($self, %args) = @_; $self->bar( answer => 42, %args, );
This lets foo have a dialog with bar that involves some overridable default behavior. A more common form of this is default constructor state.
sub new { my ($class, %args) = @_; return bless { loglevel => 0, die_randomly => 0, %args, }, $class; }
Here, the constructor provides default state that clients can override. Easy to do with named arguments; difficult to impossible with positional args.


In reply to Re: named arguments by dws
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.