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

Jean SUZINEAU jean.suzineau at wanadoo.fr
Tue Jun 13 15:25:59 CEST 2023

Le 12/06/2023 à 19:05, Steve Litt via fpc-pascal a écrit :
> Busted! I used Pascal 1984-1993
So I guess you are not familiar too with the "Result" variable which 
appeared with Delphi 1 in 1995 if I remember correctly.

nextt:= num;

can be written to as :

Result:= num;


I prefer Result because it reduces risks of confusion with recursive call
and you can eventually take the address of Result with @Result (where 
@nextt would take the address of the function nextt),
pass it by reference to another function ( e.g. FillChar( Result, 
SizeOf(Result), 0); ) ,
it behaves like a normal variable.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20230613/5a2bb3c5/attachment.htm>

More information about the fpc-pascal mailing list