Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: DWIM code would use Params::Validate

by BrowserUk (Patriarch)
on Apr 29, 2010 at 18:42 UTC ( [id://837615]=note: print w/replies, xml ) Need Help??


in reply to DWIM code would use Params::Validate
in thread Correct idiom for default parameters

Here's one reason not to use Params::Validate.

The code (minus the inline stuff), in Re: Inline Subs Revisited takes just over 4 1/2 minutes to run.

Modify those subs to validate their parameters using P:V like so:

sub max { validate_pos( @_, { TYPE => ARRAYREF } ); my ($list) = @_; my $max; for (@$list) { $max = $_ if ! defined $max || $_ > $max; } return $max; }

And it takes almost 22 minutes.

And achieves nothing that couldn't be done with die unless ref( $list ) eq 'ARRAY';. (That costs nothing measurable.)

Its like trying get better fuel economy by adding a large, copper-wound electric motor and 50Kg of batteries to your car.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: DWIM code would use Params::Validate
by Anonymous Monk on Apr 30, 2010 at 09:46 UTC
    You can disable validation for production to avoid the hit, set VALIDATION to something true

      And what happens to defaults if you disable validation?

A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://837615]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-04-20 00:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found