Flavio S. Glock skribis 2005-11-23 10:13 (-0200):
> Can we have:
>   say 1..Inf;

It's important, I think, to note that this isn't item context, but list
context. Str list context, but still list context. Which means 1..Inf
isn't stringified as a whole. &say will have an array that represents
the lazy list. It should iterate over that rather than output it all at
once, anyway, for reasons of conserving memory.

> to output an infinite stream, instead of just looping forever?

How do you imagine anything outputs infinite stuff, without looping
forever? I don't think stdout knows about our kind of laziness :)

> OTOH, it would be nice if
>   say substr( ~(1..Inf), 0, 10 )
> printed "1 2 3 4 5".

Here, 1..Inf is stringified as a whole, while with say, each of the
individual elements of the list are separately stringified. The question
of lazy strings is an interesting one. It would be very useful, and
would also allow GREAT things like

    my $revfoo := reverse $foo;
    $revfoo ~~ s/foo/bar/g;

I wonder if it's doable, though...


Juerd
-- 
http://convolution.nl/maak_juerd_blij.html
http://convolution.nl/make_juerd_happy.html 
http://convolution.nl/gajigu_juerd_n.html

Reply via email to