Errors in loop conditions can make for slow program.  Errors in recursion
can cause a stack overflow.

Steve

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Michael
S. Davis
Sent: Thursday, June 22, 2000 8:37 AM
To: Palm Developer Forum
Subject: Re: Recursion?


On Thu, 22 Jun 2000, Charles Rezsonya wrote:

> i keep hearing recursion should be avoided whiled devin' up an app.  what
> exactly does this mean?  don't call too many loops or repeated functions?
> any extra details or specs on what and what not to do would be
appriciated.
> brief is ok =)

This has always puzzeled me also.  Recursion means a routine that calls
itself.  Computing a factorial is a classic example.

But what confuses me is that a routine that recurses 3 times generally
takes up no more stack than a routine that calls another routine, which
calls a third routine.

It seems that the operative warning hers should be "don't nest
routines" too deep rather than "don't use recursion".  Each time you
call a new function, you place a lot of data on the stack AND the stack
space is limited.

In fact, it is quite possible that a routine that recurses 4 times may
use less stack that 3 separate routines that are nested.

Anyone care to explain why there is a warning against "recursion" rather
than a warning against "nesting" of functions.

Thanks


>
> l8r
> Charles Rezsonya
> Software Engineer
> IJW Software
>
>
> --
> For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/tech/support/forums/
>
>

----------------------------------------------------
Shoot-to-Win

Protect the 2nd Amendment
----------------------------------------------------


--
For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/tech/support/forums/


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to