Re: Custom errors on subsets?

2010-01-04 Thread Ovid
--- On Mon, 4/1/10, yary wrote: > From: yary > How about > multi sub foo(Any $name) { die "Houston, we have a major > malfunction."} Looks like tha would work, but it forces the developer to remember to write this extra code every time they may have a constraint failure, if they forget, we'r

Re: Custom errors on subsets?

2010-01-04 Thread yary
On Mon, Jan 4, 2010 at 5:15 AM, Ovid wrote: > Given this code: > >subset Filename of Str where { $_ ~~ :f }; > >sub foo (Filename $name) { >say "Houston, we have a filename: $name"; >} ... > Obviously the error message can use some work, but how would I customize that > error

Custom errors on subsets?

2010-01-04 Thread Ovid
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,

Re: String to Regex

2010-01-04 Thread Jan Ingvoldstad
On Sun, Jan 3, 2010 at 8:30 PM, Moritz Lenz wrote: > > But since $input can contain closures, arbitrary code can be executed. > I'd like to propose a way to compile a string to a regex which doesn't > allow code execution. > So would I. I would also like it to be the default behaviour, since th

r29454 - docs/Perl6/Spec

2010-01-04 Thread pugs-commits
Author: moritz Date: 2010-01-04 11:49:21 +0100 (Mon, 04 Jan 2010) New Revision: 29454 Modified: docs/Perl6/Spec/S05-regex.pod Log: [S05] small clarification for .match and .subst Modified: docs/Perl6/Spec/S05-regex.pod === --- doc

String to Regex

2010-01-04 Thread Moritz Lenz
Some Perl 5 programs take a regex (in string form) as input, and simply interpolate it into a regex. In Perl 6, you'd do that as my $re = rx/ <$input> /; But since $input can contain closures, arbitrary code can be executed. I'd like to propose a way to compile a string to a regex which doesn't