-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi,
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. Cheers, Moritz -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAlUWsnQACgkQT81LMIj/VkTbAwCfTsQumtjPKj1lxXZlnQ+U+0Xz uTQAn287aU2xU7m6iMFGWD+j2R+Bouy6 =LWsI -----END PGP SIGNATURE-----