Presumably, you are referring to &sub as the abnormal example where you could use goto &sub to bypass the recursion limit as seen in the following example:
According to TimToady, this actually does create a new stack, but only after the old one is stripped off. Of course you could always ignore the warning, turn off the 'recursion' warning, or recompile Perl to avoid the warning. In practice, I have never needed this kind of technique because it seems that iterative solutions aren't that difficult to come up with. In this case, the formula (n^2 + n) / 2 would do the trick.#!/usr/bin/perl use strict; use warnings; print sum( 1000 ); sub sum { my ($num, $tot) = @_; return $tot if ! $num; @_ = ($num - 1, $tot += $num); goto ∑ }
And as I am previewing this, I see BrowserUk has already said something similar - oh well.
Cheers - L~R
In reply to Re^5: Who's a thief? (recursion limitations)
by Limbic~Region
in thread Who's a thief? -- the follow up
by Ovid
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |