use Aspect? (was: Module setup argument validation)

Ziya Suzen ziya at
Sun Jul 15 03:08:10 PDT 2007

Hi there

Just realized! did not send this to the group. It's kind of late now,
so let's change the thread:

Anyone using Aspect (see message below)? Any good for production use?


---------- Forwarded message ----------
From: Ziya Suzen <ziya at>
Date: Jul 6, 2007 2:21 PM
Subject: Re: Module setup argument validation
To: Nik Clayton <nik at>

On 7/5/07, Nik Clayton <nik at> wrote:
> Oliver Gorwits wrote:
> > I'm currently looking at Params::Validate -- but my question is, are

FWIW, I used this one in a few projects. I think it is the most
popular one, but I found that my code became very messy very quickly,
trying to check all the calls. It should probably be enough to use it
on the modules api methods only.

> There seem to be quite a few.  I note on CPAN:
>      Params::Check (and Params::Check::Faster (!))
>      Params::Util
>      Params::Validate::Micro

Checking the parameters is important but it seems like they are all
creating a lot of noise in the code (Although a lot better than doing
it by hand, I suppose).

A little out side of the topic, but has anyone used Aspect seriously?

Maybe checking the parameters using something like this is cleaner? Better?

 package YoungPerson;

 sub age {
   my $self = shift;
   my $age = shift;
   # do something useful

 sub name    { ... }
 sub address { ... }

 package main;

 use Aspect;

 before {
   my $context = shift;
   die "error" if $context->params->[1] > 150;
   # call stack is different, so it might be little confusing actually
 } call 'YoungPerson::age';

It is a trivial example, but imagine that with a few subs and a few
params each with complicated validation rules and so on... you get the

BTW, I am not suggesting to use it. I don't know enough about Aspect
(performance?, reliability? debugging? war stories? ...). But looks
like a good solution to me. I though I'd mention it.

> I wrote about using Params::Validate a while back,

Nice one. Thank you.



More information about the MiltonKeynes-pm mailing list