Can you loop a Perl 6 block that's in a variable?

Viewed 214

I keep wanting to do something like this:

my $block := {
    state $n = 0;
    say $n++;
    last if $n > 3;
    };

loop $block;

Or even:

$block.loop;

I'm not expecting that this is possible but it would sure be cool if it was.

How would I find out where a particular routine comes from?

$ perl6
To exit type 'exit' or '^D'
> &loop.^name
===SORRY!=== Error while compiling:
Undeclared routine:
    loop used at line 1
2 Answers
Related