[taos-glug] Re: stack frames

> [As an
> aside, it would be interesting to see if GCC can do the optimization,
> especially given RMS' interest in Lisp...]

My understanding is that GCC can do the optimization, it is just not as
good at detecting it as SChemish languages.

> I once observed a C course where tail recursion was presented before
> while loops and while loops were explained in terms of tail recursion.
> The instructor strongly believed that tail recursion was more natural
> than loops.  Personally, it is for some things, but not always.  In my
> mind computing factorials is the classic example of when tail recursion
> is appropriate.

Using recursion over iteration (and thus doing pure functional programming
with no assignments) always has the advantage that it's easier to prove
correctness on using induction.  See
http://www.eskimo.com/~johnnyb/comptuers/Functional_Programming.html for a
little more info on the subject.

Jon


Other related posts: