develooper Front page | perl.perl5.porters | Postings from November 1999

Re: [ID 19991115.012] Localization and goto()

Ilya Zakharevich
November 16, 1999 08:10
Re: [ID 19991115.012] Localization and goto()
Message ID:
On Tue, Nov 16, 1999 at 06:08:18AM -0700, Tom Christiansen wrote:
> >$a = 5;
> >sub a { print $a }
> >sub b {local $a = 9; goto &a}
> >b;
> >This still prints 5... :-(
> And this is a problem exactly how?

> b()'s frame goes away.  So its local view of $a went away.

This is an implementation detail.  IIRC, it is documented that frame
is replaced, not goes away.  What happens/should-happen with locals
during "replacement" is debatable.

> I do not find this behaviour astonishing.

I never said it was.  However, while not astonishing, it is
unpredictable.  Different implementation might be possible.  What
happens, however, is making some "normal programming constructs" much
harder to implement.

Ilya Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About