>>>>> "b" == bugbear <bugbear@trim_papermule.co.uk_trim> writes:
b> John W. Krahn wrote:
>> 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;
>> }
b> You mean the entire construct is recognised and
b> handled as a complete "idiom", as opposed
b> to a more general evaluation model of ".." ?
it is easy to optimize (or make pseudo lazy) a .. in a for loop. all you
have to do is change how that is code generated for that special (and
common) case. passing a large .. to map is a very different story as map
expects a full list it can use. it would require more complex
recognition of a .. (and nothing else) being passed to map and a
different version of map that will do internal iteration of the .. vs
iterating over its standard input list. so they didn't try to optimize
... in the general case as it would need work on every list consuming
operator or function. and as someone said real lazy eval is the norm (in
all cases!) in p6.
uri
--
Uri Guttman ------
--------
http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ----------------------------
http://jobs.perl.org