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)
In reply to Re^11: Continuations in Perl - Returning to an arbitrary level up the call stack
by LanX
in thread Continuations in Perl - Returning to an arbitrary level up the call stack
by unlinker
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |