Super-dee-duper D features
Lutger
lutger.blijdestijn at gmail.com
Tue Feb 13 14:45:12 PST 2007
renoX wrote:
> Lutger a écrit :
>> Pragma wrote:
>>> One nit: I agree with Walter here. People do *not* "naturally think
>>> recursively".
> []
>> I'm not sure this is true. Many simple tasks are described as 'do X to Y
>> until Z,' which can be expressed easily as a recursive procedure.
>
> And even more easily as a loop.
>
>> I doubt non-programmers would think of a task as iterating over a
>> collection of objects with mutable state either. :)
>
> Uh?? Take a bunch of potatoes, peel them.
> Here you are: people are very accustomed to iterate over a bunch of
> things, changing their state.
Grab a potato, peel. Repeat procedure until done and cook the results...
This is an iterative process anyhow, but still I think recursion is a
natural way to think about tasks. It's just repetition + stop-condition
basically.
>> Recursion just has a nerdy aura around it. It probably doesn't help that
>> most programmers are learned to think iteratively too.
>
> And it doesn't help recursion that when you transform a recursive
> function to a tail recursive function so that it's not too slow, the
> result is ugly!
How is that so? Could you give an example? I'm not very familiar with
recursive programming actually...
More information about the Digitalmars-d
mailing list