in reply to Re^2: Sorting, recursion, and tail-call optimizations
in thread Sorting, recursion, and tail-call optimizations

It's not particularly special, and it doesn't optimize. I'll explain:
When you use goto &sub, you are doing a real goto. You're not calling a sub, you're just identifying a location. So the sub you leave never returns. Instead, the sub you went to returns.

The only optimization that buys you, relative to calling &sub, is that you don't have multiple returns. In my testing, I found that the use of goto more than offsets those gains.


Caution: Contents may have been coded under pressure.

Replies are listed 'Best First'.
Re^4: Sorting, recursion, and tail-call optimizations
by Limbic~Region (Chancellor) on Jan 06, 2006 at 19:48 UTC
    Roy Johnson,
    It is a shame that Perl doesn't benefit from this optimization then. In other languages, the optimization would involve re-using the same stack-frame with no pushing and popping required. In addition to the thread I already mentioned, this external article was also interesting.

    Cheers - L~R