On Wed, 10 Dec 2014 17:04:42 -0500
Uri Guttman <u...@stemsystems.com> wrote:

> it is called magic goto for that reason. it isn't really a sub call
> but a replacement of the current sub with the called one. no stack
> work is done and @_ is passed as is. it is very valuable when used
> like that but rarely needed. when you see newbies making calls like
> foo; and not know why that is dangerous, you have to teach them about
> it.

It's based on the idea of continuations, for those you want to know the
theory behind it. A continuation is passing a code reference to a sub
for it to "return" to rather than using the call stack. It works well
with exceptions: the first parameter to every sub is the normal
execution and the second is the exception handler. (The rest of the
parameters would be the regular parameters of the sub call.)

https://en.wikipedia.org/wiki/Continuation


-- 
Don't stop where the ink does.
        Shawn

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to