in reply to Re^8: 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
Well this is far beyond what the OP wanted!
And your $return->() if $return clause makes it quite esoteric ...
> Try do same with "goto"
... FWIW!
use strict; use warnings; our $target=""; sub rec { my ($i) = @_; $i++; print "i=$i $target\n"; if ($i == 3) { target($i); } if ($i == 5) { goto $target if $target; } if ($i == 7) { return; } rec($i); } sub target { local $target="TARGET"; rec(shift); TARGET: } rec(0); __END__ i=1 i=2 i=3 i=4 TARGET i=5 TARGET i=4 i=5 i=6 i=7
As I said it's only an abstraction of the goto mechanism!
Good night! =)
Cheers Rolf
( addicted to the Perl Programming Language)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^10: Continuations in Perl - Returning to an arbitrary level up the call stack
by vsespb (Chaplain) on May 19, 2013 at 09:56 UTC | |
by LanX (Saint) on May 19, 2013 at 12:44 UTC | |
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 vsespb (Chaplain) on May 19, 2013 at 13:05 UTC | |
by LanX (Saint) on May 19, 2013 at 13:12 UTC |