in reply to Re^10: Continuations in Perl - Returning to an arbitrary level up the call stack
in thread Continuations in Perl - Returning to an arbitrary level up the call stack
I'm hacking for 30 years now and never needed this! :)
In this concrete case I would only call target() if a recursion level is really expected to be a jump target, that are 6 and 3 in your examples.
(If not possible in advance I would just step back single levels (return or goto) till I reach the desired one, Something like eval "LABEL:" would be my very last resort)
And even multiple calls to target are no problem, cause the goto always jumps to the last TARGET -label in the call-stack and local $target cares about restoring previous levels. This works w/o any string- eval.
I would never use with_return in the way you are showing, because
> Your code is a bit cheat - you implemented another subroutine, just to remember point in the stack.
Nope, it's like in the original code I gave. And as I said Return::MultiLevel just uses the same technique under the hood.
Anyway let's stop it here please! =)
Cheers Rolf
( addicted to the Perl Programming Language)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^12: Continuations in Perl - Returning to an arbitrary level up the call stack
by LanX (Saint) on May 20, 2013 at 02:16 UTC | |
by vsespb (Chaplain) on May 20, 2013 at 09:03 UTC | |
by LanX (Saint) on May 20, 2013 at 12:01 UTC | |
by derby (Abbot) on May 20, 2013 at 12:13 UTC | |
by LanX (Saint) on May 20, 2013 at 12:15 UTC | |
|
Re^12: Continuations in Perl - Returning to an arbitrary level up the call stack
by vsespb (Chaplain) on May 19, 2013 at 13:05 UTC | |
by LanX (Saint) on May 19, 2013 at 13:12 UTC |