Damian Conway wrote:
> 
>    > Both are pretty much the same. Combining them, I'd say that exceptions
>    > should remain exceptional.
> 
> I'd say short-circuiting a vector operation was exceptional enough. :-)

I'd say it's exceptional sometimes, and very ordinary other times, and
I'd prefer to be the one deciding which is which.

>    > Counterproposal: grep, map, etc. define two implicit magic labels
>    > 'ACCEPT' and 'REJECT' that behave in the expected way, so you use
>    > ($first_small) = grep { ($_ < 2) and last ACCEPT } @list.
> 
> I considered this solution, but rejected it precisely because...
> 
>    > You wouldn't be able to escape the innermost enclosing grep or map
>    > with this. I'm not sure if that's good or bad.
> 
> Bad, I think.

I'm not so sure about that. And note that any die()-related proposal
doesn't give you multilevel exits either.

But if it's necessary, I suppose you could always make

Loop1Accept:Loop1Reject: grep {
        Loop2Accept:Loop2Reject: map { ... }
}

work. Though those labels really aren't in the right place.

grep { ... } @list accept1: reject1: ;

is an idea. I'd probably pick

loop1: grep { ... last ACCEPT(loop1) } @list

over either of those, though.

In the back of my mind, I keep thinking that it would be cool to have
similar control over the flip-flop operator too. I can never remember
whether C<print if /foo/ .. /bar/> will print the line containing "bar"
or not, but half the time I want the other one. But I doubt that's
related enough to tie into this.

Reply via email to