[algogeeks] Re: recursion question

2006-02-07 Thread Gene
> VC7.1, with normal Release settings, will do tail end recursion for Thanks. I have only tried V5 and V6. Neither have I tried the new gcc that uses the single assignment intermediate form. Gene

[algogeeks] Re: recursion question

2006-02-07 Thread wade
Gene wrote: > Indeed the C/C++ compilers I've used lately don't eliminate tail > recursion. GCC used to do it, but later versions don't seem to work. > MS Visual C has never worked. On the other hand, all functional > language compilers are similar in this respect to Scheme. They need to > be

[algogeeks] Re: recursion question

2006-02-06 Thread Gene
Indeed the C/C++ compilers I've used lately don't eliminate tail recursion. GCC used to do it, but later versions don't seem to work. MS Visual C has never worked. On the other hand, all functional language compilers are similar in this respect to Scheme. They need to be since tail recursion is

[algogeeks] Re: recursion question

2006-02-06 Thread H.
This is interesting you say this (and very timely), because in a C++ data structures course I'm taking, we're creating recursive box trace diagrams. Even in tail-recursive functions, we draw it such that the stack keeps on growing. So I'm curious if we draw it this way because: 1. you can never c

[algogeeks] Re: recursion question

2006-02-06 Thread Gene
There is a lot of work on this in the literature on functional languages, where rewriting recursions can lead to aymptotic speedups. Often the idea is to get from a general recursion to tail recursion in order to avoid stack growth and value copying.