A. Pagaltzis wrote:
* Dave Rolsky <[EMAIL PROTECTED]> [2005-08-15 14:55]:

Params::Check is in pure Perl, P::V is all in XS except for a
few bits, so I'd guess P::V is going to be faster.


But faster than merely locking a hash for a moment to keep
unwanted bits out of it too?

Regards,

It's not really clear what Ovid's objective function is and whether execution speed is the issue. Points I heard include:

* Don't want to type this repetitively
* Don't want to forget to do something I should be doing regularly
* Large/confusing documentation is a turn-off to use
* Don't want a "diesel engine"

Does "diesel engine" mean slow? large? complex? The only question is whether Params::Val9date

Personally, I like Params::Validate because the spec is very flexible and I like something that I can use for simple things like required/optional parameter checking or that I can scale up to more involved things like argument validation or dependency checking. For Ovid's stated needs, this approach using Param::Validate is sufficent:

use Params::Validate;

sub tweedledum {
    my %args = validate( @_, {
        foo     => 1, # required
        bar     => 1, # required
        bam     => { default => 'default' },
        wibble  => { default => 0         },
        wobble  => { default => 0         },
    });

    # process
}

It's hard to imagine something more spare than that that is still intelligible and maintainable. It even generates the error messages, which, aside from the spec, is the lengthier thing to hand-roll. (The "check for extra/missing keys" bit is actually really simple.) Even Params::Check is not much different in terms of API.

And I'm not sure if argument processing is really the best point of optimization. If argument checking time is equal or greater than subsequent processing, and that subroutine really is the bottleneck, then it should probably just be inlined anyway.

Regards,
David

Reply via email to