[fpc-pascal] fpc isn't optimised for tail recursion, is it?

Steve Litt slitt at troubleshooters.com
Mon Jun 12 19:53:12 CEST 2023

Marco van de Voort via fpc-pascal said on Mon, 12 Jun 2023 09:12:22

>On 12-6-2023 08:15, Nikolay Nikolov via fpc-pascal wrote:
>Shouldn't the recursive call assign the result?
>> nextt(num - 1);   
>nextt:=nextt(num - 1);
>if you don't use the result, the whole call may be optimized away?

Thanks Marco,

You're right, of course. I'm not using my function return. That being
said, as far as I know, FPC can't optimize for tail recursion if I do
use the function return in any way. So I didn't use the function return.

Of course, you bring up a point of cleanness and style. If I don't use
the function return, I should have made it a procedure instead of a

Anyway, I learned from my forays into Guile that I don't yet have a
good mental model of functional programming, hence my confusion.



Steve Litt 
Autumn 2022 featured book: Thriving in Tough Times

More information about the fpc-pascal mailing list