|Just another Perl shrine|
Re^2: cross scope gotos?by LanX (Chancellor)
|on Apr 06, 2010 at 12:21 UTC||Need Help??|
> It replaces the current call frame, thus removing the current frame from the dynamic scope
which is part of the answer...
But it's not the scoping visibility of the label variable which hinders the jump back to work like you can see in the following example:
It's the point that gotos are only possible to destination within the scope of the call chain.
BUT It may not be used to go into any construct that requires initialization, such as a subroutine or a "foreach" loop.
Since jump() adds a new call frame, there is no more initialization of the old frame needed when jumping back, just closing the new frames.
But with goto &jump the old call frame is replaced and all links to possible labels there!
So jumping back would imply a re-initialization of this frame, which is not possible...
I got it, thanks for discussing it! :)