Re: Lazy evaluation?



Michele Dondi wrote:
On Tue, 13 Feb 2007 20:14:13 -0600, Rob Hoelz <hoelz@xxxxxxxx> wrote:
local $\ = "\n";
foreach $num (1..1000_000_000) {
print $num;
}

I seem to remember that this particular one is optimized, but I'm not
really sure if up to the point of lazy evaluation.

The above (foreach list) *is* lazy evaluated (at least
in my in 5.8.8/Linux), whereas the list in

print map { exit } (1..1000_000_000);

is not (panic: realloc at lazy.pl al line ##).

Regards

Mirco
.



Relevant Pages

  • Re: Lazy evaluation?
    ... foreach $num { ... really sure if up to the point of lazy evaluation. ... The above (foreach list) *is* lazy evaluated (at least ... actually required for the printfunction which is not what perl does. ...
    (comp.lang.perl.misc)
  • Re: Lazy evaluation?
    ... foreach $num { ... does Perl use lazy evaluation? ...
    (comp.lang.perl.misc)
  • Lazy evaluation?
    ... foreach $num { ... does Perl use lazy evaluation? ...
    (comp.lang.perl.misc)
  • Re: Bidirectional mapping
    ... SAT SUN]? ... For quick and dirty and highly readable I usually do it like: ... foreach { ... set day_num($day) $num ...
    (comp.lang.tcl)