On Tue, Jan 5, 2010 at 1:07 AM, Ovid <publiustemp-perl6langua...@yahoo.com>wrote:
> --- On Mon, 4/1/10, yary <not....@gmail.com> wrote: > > > From: yary <not....@gmail.com> > > > 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're back to the old, cryptic message. It would be much nicer to > be able to do this (psuedo-code, obviouly): > > subset Filename of Str where { $_ ~~ :f } > :OnFail { "No such file: '$_'" } > subset Celsius of Num where { $_ >= -273.15 } > :OnFail { "Celsius temperature should be a Num >= -273.15, not '$_' " } > > With something akin to that, developers won't have to write extra > boilerplate every time a constraint fails. Plus, the code is friendlier :) > 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. -Scott -- Jonathan Scott Duff perlpi...@gmail.com