On Tue Jan 13 02:48:55 2009, richardh wrote:
> Control traits, eg., NEXT, CATCH do not seem to work.
> 
> They generate syntax errors.
> 
> Control traits not listed in features status list.
> 
> I tried the following (result could be done another way, I know):
> 
> my @arr = ( 1,2,3,4,5,6 );
> my $collect;
> for @arr {
>     NEXT { $collect += $_ }
> } while $collect < 7;
> 
> say $collect; # should be 10
> 
> Is this code correct?

Sorry about the very long delay. CATCH blocks have been implemented in rakudo, 
but NEXT 
blocks have not  yet. (So, changing this ticket to be a TODO for next blocks.

FYI, the syntax you have here is not correct; you cannot have a for loop with a 
postfix while 
conditional - This might have been allowed when the ticket was opened, I'm not 
sure. Also, 
you don't need ()'s when declaring the array.

Here's some code from masak++ to show NEXT working in pugs:

10:40 < masak> pugs: for 1, 2, 3 { NEXT { say "!" }; .say }
10:40 <+p6eval> pugs c943eeb: OUTPUT«1␤!␤2␤!␤3␤!␤»

But failing in rakudo:

10:42 < [Coke]> rakudo: for 1, 2, 3 { NEXT { say "!" }; .say }
10:43 <+p6eval> rakudo 25af2d: OUTPUT«===SORRY!===␤CHECK FAILED:␤Undefined
                routine '&NEXT' called (line 1)␤»

Thanks for the report, we'll keep it open until NEXT works!
-- 
Will "Coke" Coleda

Reply via email to