... you can reduce the size and time of the stack by using some kind of "global" variable instead of passing everything by parameter. Pascal had a mechanism for this (nested subroutines) that C lacks...
If a nested subroutine refers to variables from an enclosing sub, it needs a pointer to the enclosing sub's stack frame. This means that the compiler is passing around an extra parameter that you don't see. No free lunch here.
We neither have to pass a reference into the sub to hold our results, nor ...
Correction: You don't have to pass a reference into the sub explicitly. Perl does it for you automatically. The mechanism for that might be a bit more efficient than using ordinary references, but that's not necessarily true beyond the current incarnation of Perl.
In reply to Re: Re: Re: Re: Re: Recursion Alternatives?
by no_slogan
in thread Recursion Alternatives?
by Cabrion
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |