Tony wrote:
"Gavin Deane" <de*********@hotmail.comwrote in message
news:11**********************@16g2000cwy.googlegro ups.com...
Tony wrote:
Is there any value to pursuing program designs that mimimize
the mainline call stack?
That's a general question. As with any optimisation question, the
general answer is "no need".
I wasn't necessarily asking from an optimization standpoint. My concern
would be more from the robustness standpoint: if there's a larger surface
area for potential corruption, then maybe it's wise to minimize that.
Well, no. Recursive functions /can/ be difficult to debug or validate.
They /can/ also be slower than their loopy counterparts. It is rare
that this is really important though and often times an algorithm is
just plain simpler in a recursive form.
Now, as to the general question. How would you alleviate the "problem"
of stack "depth" should you see such a problem? Well, the obvious
answer would be to pull all the functions you are calling up into their
caller so that instead of having a bunch of small, simple, easy to
manage functions you have one great big one. That's bad.
No, there is no need to pursue designs that minimize call depth...in
fact I would say they should be avoided in almost all, if not all,
situations.