On Mar 28, 2015 8:54 AM, "Moritz Lenz" <mor...@faui2k3.org> wrote: > On 28.03.2015 12:27, Tom Browder wrote: > > I like the subroutine arg handling in Perl 6. Is there any simple > > way to attach a short error msg in place of or additive to the > > default for, say, a missing arg? > > You can always use multi subs, and use a catch-all candidate which > produces the error message. > > multi thingy($x) { $x + 42 } > multi thingy(|c) { die "Must call &thingy with exactly one argument" } > > Though IMHO that's usually not worth the trouble; you get the error > message only for programming errors, not for user errors; and > programmers should be able to understand the error message (or we need > to improve the error messages, if that's not the case). > > Also it makes it harder for others to extend your API by providing > additional multi candidates.
Agree--looks like we need some of Damien Conways wonderful CPAN modules ported ASAP! Cheers! -Tom