No such thing as a small change | |
PerlMonks |
Re (tilly) 5: Poor Man's Prototyping?by tilly (Archbishop) |
on Nov 26, 2001 at 20:56 UTC ( [id://127580]=note: 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: 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 Section
Seekers of Perl Wisdom
|
|