David Storrs writes:
> On Sat, Jul 03, 2004 at 01:02:34AM -0600, Luke Palmer wrote:
>
> > But indeed there are cases where it is a problem:
> >
> > my $x = 2;
> > sub mklist () {
> > return map { 2 * $_ } 0..10;
> > }
> >
> > my @list = mklist;
> > say @list[0..4];
On Sat, Jul 03, 2004 at 01:02:34AM -0600, Luke Palmer wrote:
> But indeed there are cases where it is a problem:
>
> my $x = 2;
> sub mklist () {
> return map { 2 * $_ } 0..10;
> }
>
> my @list = mklist;
> say @list[0..4]; # 0 2 4 6 8
> $x = 1;
> say @list;
Brent 'Dax' Royal-Gordon writes:
> As you mentioned below, this causes problems if the code in question has
> side effects. But there are other cases where it messes up:
>
> sub even($_ = $CALLER::_) { ! $_ % 2 }
> my @e=grep { even() } 1..1024;
> #Okay, we don't need &even anymore..
Luke Palmer <[EMAIL PROTECTED]> writes:
> Well, perhaps not. Theoretically, at this point, $file has been
> read completely. It's just that it's lying and it hasn't really.
> But if you try to read again, it should resync and things should
> work properly.
That's all well and good if the fileha
Alexey Trofimenko wrote:
apply to it perl6 GC, which wouldn't always free memory immediately,
so it could eat 3_000_000 or more.
Parrot runs a DOD (Dead Object Detection) sweep whenever its memory
pools fill up, so this is probably a far smaller problem than you
suggest. (If there still isn't
Alexey Trofimenko writes:
> what I want to ask - would map and grep return an iterators too?.. if
> it's true, then previous construct becames very memory efficient, like if
> I write
> loop ( ... ; ... ; ... ) {...; next if ...; ...; say}
Yep, they will.
> hm.. It could be a little too fun
consider this:
say for map {...} grep {...} map {...} 1..1_000_000
as far as I can imagine, in perl5 it does:
1)flatten 1..1_000_000 into anonimous array; (maybe in this particular
case it is optimized in perl5, like it done in C.. I don't know.)
2)map trough it elements and store results in