in reply to Re^3: Perl6 lazy list of code blocks
in thread Perl6 lazy list of code blocks

I don't know if it's a bug, it might be ordinary closure cloning at work.

This works too:

my $s = { state $n=-1; $n++; sub ($x,$y) { $x+$y+$n } }; my @foo = $s ... *; say @foo[0].(3,5); say @foo[1].(3,5); say @foo[2].(3,5);

Replies are listed 'Best First'.
Re^5: Perl6 lazy list of code blocks
by aes (Initiate) on May 24, 2012 at 10:34 UTC
    Ah, but you're repeating the sequential access behavior that hides the bug. Try instead reversing the access order and you'll see the "high water mark" bug.
    say @foo[2].(3,5); say @foo[1].(3,5); say @foo[0].(3,5);
    ...produces...
    10 10 10