Would it make sense to have the failure bound to the function parameter
rather than the subset? eg.:
sub foo (Str $name where { $_ ~~ :f } else { die "Houston, we don't have a
file" } ) { ... }
Just a thought...
On Tue, Jan 5, 2010 at 1:07 AM, Ovid
wrote:
> --- On Mon, 4/1/10, yary wrote:
>
>
Perhaps you could create an error function that temporarily sets the
default error message (does perl 6 still have the $! variable?) and
returns false; so:
subset Filename of Str where { $_ ~~ :f or error ( "No such file: '$_'" ) }
Of course, that's a rather narrowly-defined function, as it's
On Tue, Jan 5, 2010 at 1:07 AM, Ovid
wrote:
> --- 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 t
On Tue, Jan 05, 2010 at 11:52:42AM -0500, Solomon Foster wrote:
: On Tue, Jan 5, 2010 at 11:36 AM, Ovid
: wrote:
: > --- On Tue, 5/1/10, Solomon Foster wrote:
: >
: >> From: Solomon Foster
: >
: >> > Is this a bug or just documented behavior that I don't
: >> know about?
: >>
: >> fail just retu
On Tue, Jan 5, 2010 at 11:36 AM, Ovid
wrote:
> --- On Tue, 5/1/10, Solomon Foster wrote:
>
>> From: Solomon Foster
>
>> > Is this a bug or just documented behavior that I don't
>> know about?
>>
>> fail just returns an uncalled exception. What does
>> that do in a where block?
>
> I knew it ret
--- On Tue, 5/1/10, Solomon Foster wrote:
> From: Solomon Foster
> > Is this a bug or just documented behavior that I don't
> know about?
>
> fail just returns an uncalled exception. What does
> that do in a where block?
I knew it returned an uncalled exception, but I'm still not expecting t
On Tue, Jan 5, 2010 at 11:18 AM, Ovid
wrote:
> --- On Tue, 5/1/10, Jonathan Scott Duff wrote:
>
>> From: Jonathan Scott Duff
>
>> I'd imagine that the functionality will fall
>> out of the ability to have nice failures because surely
>> something like the following works now:
>>
>> subset Filen
--- On Tue, 5/1/10, Jonathan Scott Duff wrote:
> From: Jonathan Scott Duff
> I'd imagine that the functionality will fall
> out of the ability to have nice failures because surely
> something like the following works now:
>
> subset Filename of Str where { $_ ~~ :f or
> fail "No such file: '
--- 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
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
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,
11 matches
Mail list logo