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

Your first suggestion...
my @blocks := (0..*).map: -> $n { -> $x, $y { $x * $y * $n } };
...seems just right, but it hangs rakudo-star-2012.04.

It does not hang on my machine, also tested with rakudo star 2012.04.

One way it could possibly hang on yours is if you use it in the interactive shell (REPL). Because that tries to get a string representation of the return value (here the lazy list), and that doesn't work for an infinite list. It would be nicer to not hang, but detecting if a lazy list is infinite is a tricky business.

If you still want to use the REPL, you can just but another statement after it on the same line:

> my @blocks := (0..*).map: -> $n { -> $x, $y { $x * $y * $n } }; 1; 1

That way the 1 at the end is converted to a string, not the infinite list.

Replies are listed 'Best First'.
Re^4: Perl6 lazy list of code blocks
by aes (Initiate) on May 24, 2012 at 10:27 UTC
    I'm not using the REPL. Curious. I think I'll file a rakudo bug report. Thanks.