Re: Lazy evaluation?
- From: "John W. Krahn" <someone@xxxxxxxxxxx>
- Date: Wed, 14 Feb 2007 13:59:33 GMT
Mirco Wahab wrote:
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
That is not lazy evaluation. Perl is just internally evaluating:
foreach $num (1..1000_000_000) {
print $num;
}
As:
for ( $num = 1; $num <= 1000_000_000; ++$num ) {
print $num;
}
Lazy evaluation would imply that the assignment to $num is delayed until it is
actually required for the print() function which is not what perl does.
John
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall
.
- Follow-Ups:
- Re: Lazy evaluation?
- From: bugbear
- Re: Lazy evaluation?
- References:
- Lazy evaluation?
- From: Rob Hoelz
- Re: Lazy evaluation?
- From: Mirco Wahab
- Lazy evaluation?
- Prev by Date: Re: Become more productive with Vista Speech Recognition.
- Next by Date: FAQ 4.64 How can I get the unique keys from two hashes?
- Previous by thread: Re: Lazy evaluation?
- Next by thread: Re: Lazy evaluation?
- Index(es):
Relevant Pages
|