[fpc-pascal] Recursion optimization by compiler
José Mejuto
joshyfun at gmail.com
Sat Sep 4 16:45:25 CEST 2010
Hello FPC-Pascal,
Saturday, September 4, 2010, 9:07:57 AM, you wrote:
RB> This a misunderstanding of way recursion can be flattened
RB> into a loop. It's especially not useful because the transformed
RB> version still uses a stack, so it doesn't execute in constant
RB> space.
I know, but as far as I know it is the only way to get exactly the
same functionality whichever the recursion function works (using a
stack different than the default stack). If the recursion function is
not the last function it can not be "optimized" in such way, moreover
most of that "tail recursive" functions are easy to be rewritten as a
while end loop.
Anyway I do not have any kind of degree in computer science or alike
so I could be completly wrong :)
--
Best regards,
José
More information about the fpc-pascal
mailing list