in reply to Re^7: When every microsecond counts: Parsing subroutine parameters
in thread When every microsecond counts: Parsing subroutine parameters
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:
I'd set that to be: more than 4.
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^9: When every microsecond counts: Parsing subroutine parameters
by rhesa (Vicar) on May 18, 2008 at 21:48 UTC | |
by BrowserUk (Patriarch) on May 18, 2008 at 22:34 UTC |