On Sat, Jul 31, 2010 at 04:29:00PM -0400, Aaron Sherman wrote:
> My problem with that is that it's a really odd use of given/when, and given
> the implicit smart-match, it doesn't make much sense. Now, to slightly
> backtrack, I do agree that there should be at least one way to do something,
> and if that were the only way to perform independent tests within a given,
> I'd agree. Thankfully, it's not:
> 
>  given $_ {
>    when /clock/ { say "clock" }
>    if time > $limit { say "tick" }
>    default { say "tock" }
>  }

The problem with this formulation is that a successful 'when'
exits the block, while a successful 'if' does not.  This is one
of the significant differences between 'if' and 'when'.

So in the above, the default say "tock"  is executed regardless
of the result of the time > $limit test.

> Well, since it's easy to do both, as demonstrated above, I think we can
> agree that we've satisfied the first rule.

It's not as easy to do both as your example seems to illustrate.
Perhaps you can provide a better example that does illustrate
testing for a condition that also results in exiting the C<given> 
block?

Pm

Reply via email to