Given this code:
subset Filename of Str where { $_ ~~ :f };
sub foo (Filename $name) {
say "Houston, we have a filename: $name";
}
my Filename $foo = $*EXECUTABLE_NAME;
foo($foo);
foo($*EXECUTABLE_NAME);
foo('no_such_file');
We get this output:
Houston, we have a filename: /Users/ovid/bin/perl6
Houston, we have a filename: /Users/ovid/bin/perl6
Constraint type check failed for parameter '$name'
in Main (file src/gen_setting.pm, line 324)
Obviously the error message can use some work, but how would I customize that error message (assuming such will be possible in the future)? Clearly there will be many cases where a custom error message for constraint failure could make life much easier for developers.
Cheers,
Ovid
--
Buy the book - http://www.oreilly.com/catalog/perlhks/
Tech blog - http://use.perl.org/~Ovid/journal/
Twitter - http://twitter.com/OvidPerl
Official Perl 6 Wiki - http://www.perlfoundation.org/perl6
Thread Next