develooper Front page | perl.perl5.porters | Postings from March 2013

Infinite loop in for (@a) { push @a, $_ }

Thread Next
From:
demerphq
Date:
March 19, 2013 11:18
Subject:
Infinite loop in for (@a) { push @a, $_ }
Message ID:
CANgJU+WcdVv5G1yS1p=iWVerJtuszmaLDoq_k-ZmuXmJfMhY_w@mail.gmail.com
This code is an infinite loop.

   my @a = ("A".."D");
   for (@a) {
       say;
       push @a, $_;
   }

I think this is a regression as compared to how it would have worked
when for (@a) operated on the stack and put a copy of @a on the stack.

Does anyone agree? I would expect this to be the same (more or less) as:

push @a, @a;

And not an infinite loop.

cheers,
Yves

-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About