On Fri, Aug 04, 2000 at 02:59:06PM -0000, Perl6 RFC Librarian wrote:

> Howeverm it I<is> possible to cause a C<case> statement to "fall-through". If a
> C<next> is executed within a C<case> block, control is immediately 
> transferred to the statement following the C<case> block.
> For example:
> 
>       switch ($count) {
>               case 0                  { print "nothing\n"; next }
> 
>               print "fell through!\n";
> 
>               case /^\d$/             { print "single\n"; next }
> 
>               print "fell through again!\n";
> 
>               case sub{$_[0]%2}       { print "odd\n" }
>               else                    { print "even\n" }
>       }

This seems backwards to me. Everywhere else in perl next would cause the
next iteration of a block/loop. If a switch is considered like a loop
then next would be the same as 'break' in C, as would last and redo
would repeat the switch.

this would mean that fallthrough would be the default and the user
would need a last; to break out;

Of course if a case was a block containing loops etc. the switch statement would
need a label so you would type C<last SWITCH>

Graham.

Reply via email to