A goto-like usage of a function

Terry Reedy tjreedy at udel.edu
Thu Jul 29 22:25:31 EDT 2004


"Bart Nessux" <bart_nessux at hotmail.com> wrote in message
news:41091DD7.6070500 at hotmail.com...
> I understand recursion to be a loop or a loop to
> be recursion... however you prefer to look at it.

If you qualify the recursion as simple (non-branching), then I agree.  They
are two different syntaxes for expressing simple induction (repetition with
variation). Looping can be thought of as anonymous within-frame recursion.
And some languages implement tail recursion this way.  But Python does not,
and I believe a majority of Pythoneers prefer the loop version.  For enough
repetitions, it is mandatory.  And for general sequence processing, for
loops are most excellent.

Branching recursion is more complicated.  In general, three loops are
required to replace one (branching) recursion, but that's another story...

Terry J. Reedy






More information about the Python-list mailing list