Marco van de Voort via fpc-pascal said on Mon, 12 Jun 2023 09:12:22 +0200 >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 function. Anyway, I learned from my forays into Guile that I don't yet have a good mental model of functional programming, hence my confusion. Thanks, SteveT Steve Litt Autumn 2022 featured book: Thriving in Tough Times http://www.troubleshooters.com/bookstore/thrive.htm _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal