On Tue, Jun 08, 2004 at 08:38:52PM -0000, Michael G Schwern wrote: > A co-worker exhausted his machine's memory trying to compile this: > > for ( '', 'a'..'zzzzzzz' ) {} > > B::Deparse (using 'zzz') reveals that Perl is trying to build that > entire list in memory. The range optimizer seems to only kick in when > there's nothing but a range in there. > > Our work around is: > > for ( $i = ""; $i ne "aaa"; ($i = $i ? ++$i : "a") ) { print $i } > > Bug/optimizer-miss appears in 5.6.1, 5.8.1 and 5.8.3. I'm not sure how this can be construed as a bug. In the general case I'd expect 'a'..'zzzzzzz' to generate a large list, since P5 doesn't have P6's lazy lists. It just so happens that C<for (X..Y)> is special-cased, but I don't see why that should lead to a general expcatation of lazy-listness? Dave. -- Nothing ventured, nothing lost.Thread Previous | Thread Next