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

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

Thread Previous | Thread Next
From:
Leon Timmermans
Date:
March 19, 2013 16:45
Subject:
Re: Infinite loop in for (@a) { push @a, $_ }
Message ID:
CAHhgV8jAhuKZ_atgmdZ-081eWeZPzfUXrQi-rxGf4Q1kCA6uOw@mail.gmail.com
On Tue, Mar 19, 2013 at 12:18 PM, demerphq <demerphq@gmail.com> wrote:
> 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.

Quite frankly, I think an infinite loop is a more sane way to handle
this than what we did before (crashing occasionally). It's either this
or dieing.

Leon

Thread Previous | 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