--- On Tue, 5/1/10, Jonathan Scott Duff <perlpi...@gmail.com> wrote:

> From: Jonathan Scott Duff <perlpi...@gmail.com>

> 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: '$_'" }
> Perhaps s/fail/die/, but that seems like a means
> to your desired end. 

Ah, the die works fine.  However, "fail" causes that sub call to be skipped 
altogether:

    subset Filename of Str where { $_ ~~ :f or fail "$_ is not a filename" };

    sub foo (Filename $name) {
        say "Houston, we have a filename: $name";
    }

    foo($*EXECUTABLE_NAME);
    say "before";
    foo('no_such_file');
    say "after";

Output:

    Houston, we have a filename: /Users/ovid/bin/perl6
    before
    after

Is this a bug or just documented behavior that I don't know about?

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


Reply via email to