A goto-like usage of a function

Grant Edwards grante at visi.com
Thu Jul 29 12:06:49 EDT 2004


On 2004-07-29, Bart Nessux <bart_nessux at hotmail.com> wrote:

> I understand recursion to be a loop or a loop to 
> be recursion... however you prefer to look at it.

A loop uses a finite amount of memory no matter how many times
it loops.  Recursion uses an unbounded amount of memory unless
it's tail recursion and the compiler transforms it into a loop
[the Python compiler does not].

> Whether it's a function calling itself until the user gets the
> input right or a while statement w/i a function waiting for
> correct input... IMO, it's the same thing. With that said,
> there may be performance issues that I'm unaware of that make 
> your approach better or worse than mine...  outside that, I
> think either approach is worthwhile.

Just make sure you place bounds on the depth of the recurstion
so you don't run out of stack space.

-- 
Grant Edwards                   grante             Yow!  Vote for ME
                                  at               -- I'm well-tapered,
                               visi.com            half-cocked, ill-conceived
                                                   and TAX-DEFERRED!



More information about the Python-list mailing list