I have finally taken the time to release two important modules, which
are building blocks for other modules of mine that are still pending
release in the wait queue... I just lack time ticks to process them ;-)
They don't work with 5.6.0, so don't even try it. They work with 5.005_03
of course, and where tested OK by myself with 5.6.1-TRIAL1 on Linux.
The first module is Getargs::Long, which gives easy named parameter usage
in routines, with optional type checking of the arguments:
use Getargs::Long;
sub f {
my ($x, $y ,$z) = getargs(@_, qw(x=ARRAY y=i z=s));
....
}
# And now for the call... Argument order does not matter, of course
f(-x => ['a', 'b'], -y => 1, -z => "foo");
The second module is Devel::Datum (it uses Getargs::Long) which provides
some support for Programming by Contract, and flexible tracing abilities,
which can be configured via a mini-language. Devel::Datum cooperates with
Log::Agent for its tracing routines.
It is very different from Class::Contract, in that it does not alienate
the Perl syntax too much, although it adds some clutter of its own:
use Devel::Datum qw(:all on);
sub routine {
DFEATURE my $f_, "optional message";
my ($a, $b) = @_;
DREQUIRE $a > $b, "a > b";
$a += 1; $b += 1;
DASSERT $a > $b, "ordering a > b preserved";
my $result = $b - $a;
DENSURE $result < 0;
return DVAL $result;
}
The Devel::Datum module is a co-development between Christophe Dehaudt and I.
It is derived from a C/C++ runtime called... DATUM, authored by the same
people...
Raphael Manfredi & Christophe Dehaudt