Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I said I was passing through a hash, and you assumed that I was passing through a reference to a hash?

Bad assumption.

I pass through a list of key/value pairs, and construct the hash inside of the function. Why? So that I can then proceed to do destructive processing on said hash without bothering my caller. Furthermore it allows the easy setting of a few optional defaults in a wrapper function:

sub some_wrapper { # Do some wrapper type stuff here. real_function( key1 => $default1, key2 => $default2, @_ ); }
But you cry about efficiency! I respond, So what? If my code is performance critical, I will worry about performance. Usually it isn't, and I will worry about my sanity first, second, and fourth. (Third is other people's sanity or lack thereof.)

As for your complaint, true. In languages where arguments are positionally placed, more than 2-3 arguments gets cumbersome. I find that with named arguments the average person's threshold goes up. 5-6 arguments is not problematic. Our name association goes father than the memorization of orders of arguments, and the type of error changes from messing up argument order (hard to catch) to typos (which I place automated checks for). And people who can consult documentation are extremely tolerant of large numbers of possible optional arguments, just so long as they are pretty much independent.

In reply to Re (tilly) 5: Poor Man's Prototyping? by tilly
in thread Poor Man's Prototyping? by tame1

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

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2024-04-12 11:43 GMT
Find Nodes?
    Voting Booth?

    No recent polls found