On Sat Nov 24 08:16:13 2012, alh wrote: > On Sat, Nov 24, 2012 at 10:34 AM, Father Chrysostomos via RT < > perlbug-followup@perl.org> wrote: > > > > > > > Is there any other case besides for/foreach that 'a..z' should > iterate on > > > the fly rather than immediately generate a list in memory? > > > > I hadn’t thought of that, but if it could iterate on the fly in more > > places it would allow for more idiomatic code. > > > > > I see these as being sensible uses of iteration: > > for ('a'..'z', qw(cat dog mouse), 1..10) { print $_ } > > my @found = grep { $_ =~ /./ } 1..10; > > my %hash = map { $_ => 1 } 1..10*;* > > But should this iterate at runtime or be pregenerated as it is now? That’s a hard question. :-) > > my @arr = (1..10); > > If it's in a sub that's never hit, there's a memory saving there if it > iterates when requested. > > -- Matthew Horsfall (alh) -- Father Chrysostomos --- via perlbug: queue: perl5 status: open https://rt.perl.org:443/rt3/Ticket/Display.html?id=30123Thread Previous | Thread Next