[fpc-pascal] Recursion optimization by compiler
bihar_anwar at rocketmail.com
Fri Sep 3 15:06:30 CEST 2010
September 3, 2010 7:17:57 PM, José Mejuto wrote:
> That kind of "optimization" to me only seems interesting in
> two possible situations, when calling functions is high
> costly or when there is a very limited stack amount (really,
> really small). From my point of view if you need more that
> 1MB of stack size I'm quite sure that you are doing
> something wrong, because around 65000 recursion levels
> looks not very good.
> The recursion "optimization" is being done using regular RAM
> as a stack.
Thanks Jose, I agree with you. Since in my case I need less than 1MB of stack
size, so there is no reason to use nonrecursive/iterative approach. Furthermore,
recursion is more readable.
Thanks Jose for the code snippets. You introduce TStack that I'm not aware of.
First, just curious, have somebody here ever benchmark performance between
native stack and regular RAM as a stack?
Second, does FPC understand "tail recursion"?
More information about the fpc-pascal