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

Re: [ID 19991115.012] Localization and goto()

From:
Ilya Zakharevich
Date:
November 16, 1999 08:10
Subject:
Re: [ID 19991115.012] Localization and goto()
Message ID:
19991116111049.A21646@monk.mps.ohio-state.edu
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



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