Sorry, and I'm not trying to start an argument by way of reply. In other languages goto is a jump. In perl I recalled that goto &foo wasn't "traditional" goto, I assumed (incorrectly) that calling it this way instead of implementing with a line label was the source of the leak. The docs say that localized variables are cleared, but says nothing about clearing anything else. Just some weird magic used for AUTOLOAD. In the end, your are correct that I'm not even a novice in tail-recursion, and probably should have kept my mouth shut, or at least qualifed my post. | [reply] |
Cabrion,
No worries. In languages that have tail recursion optimizations built in, there is no need for goto at all (just have the sub call itself). This is mostly the case for functional languages like Haskell. In perl, trying to achieve this yourself isn't much of a gain. It does avoid the deep recursion warning though.
This type of optimization falls into the category of unrolling loops. If your language doesn't do it for you, trying to do it yourself can be prone to error. If you are interested in computer science, reading the links I sent may be of use.
| [reply] |