On Mon, 20 Nov 2017 12:13:47 -0800, ronaldxs wrote: > What about a native perl6 range loop? Couldn't there be some way for > Perl 6 / Rakudo to generate code competitive on a small range with the > "native-loop" example? > > perl6 -e ' > { > my int ($a, $one, $three) = (42, 1, 3); > for ^10_000_000 { $a += $one + $a%$three }; > say now - ENTER now; > say $a > }'
This code will actually be turned into a `loop` loop by the optimizer at compile time. If you type the block to have a signature of `-> int $_ --> Nil` it'll get faster. The optimizer doesn't do anything like that for the `^$limit` case, however.