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.
RIP an inspiration; A true Folk's Guy

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.