Subj : Re: Do all programming languages use files? To : comp.programming From : mschaef Date : Thu Sep 01 2005 09:46 am In article <1125579611.621410.58410@o13g2000cwo.googlegroups.com>, Ed Prochak wrote: > >Richard Heathfield wrote: >> Ed Prochak said: ... >> That depends on your point of view! I once worked on a project where we were >> converting a load of QBasic programs (written by actuaries) into C. I asked >> one of these actuaries why they used recursion so much. His reply was >> illuminating: "Quite often we want to do , so we do it, and then we >> see if we've done it enough. If not, we do it again!" >> >> Clearly, he saw no real distinction between recursion and iteration. (Yes >> yes yes, I do see your point of view - but there are other points of view!) > >Whether actuaries understand the difference is irrelevant. There is a >real difference. Yes, iteration is a subset of recursion. Tail recursion is equivalent to a loop, and can be compiled as such. With nested procedures/scopes, it's not even all that inconvenient to write. It also offers a couple side benefits over 'plain' loops: the loop is named almost by default, and if you keep away from assignment statements and stick to function paramaters, it becomes possible to more predictably think about when your loop variables change. Non-tail recursion is significantly more expressive, obviously. -Mike -- http://www.mschaef.com .