On Wed, 17 Aug 2005, Dave Rolsky wrote:
Type Validation, "isa", & "can"
Params::Validate allows for several ways to check the _value_ of a parameter.
One way is to specify a primitive type like "SCALAR" or "ARRAYREF". In P6 we
have that with this:
sub date (Scalar +$year is required, ...)
I'm not sure is "Scalar" is a valid type though, but that's ok because we
have better types built in. In this case we should really use "Int" for a
year.
And another question. How will I make Perl6 not do automatic coercion for
me. If I have this sub:
sub date (Int +$year is required, +$month, +$day)
and someone does this:
date('this year', 12, 1);
I'd prefer for this to fail, rather than giving me 0000-12-01! I vaguely
remember a mention of "use strict 'types'" either on this list or hanging
out with some pugs folks at YAPC.
-dave
/*===================================================
VegGuide.Org www.BookIRead.com
Your guide to all that's veg. My book blog
===================================================*/