In a way, yes, but not quite the same, since multiple calls to the nested function would still redirect to the same block of code rather than being inlined at each call.  I suppose more similar to the old GOSUB; RETURN combination in old versions of Basic, and the nested routine slotted either at the end of the parent function or, if the compiler is intelligent enough, right after one of the function calls (in effect, inlining it at this point) so the peephole optimizer can then remove a zero-distance jump.

Gareth aka. Kit

On 01/10/2020 22:10, Ryan Joseph via fpc-devel wrote:

On Oct 1, 2020, at 10:37 AM, J. Gareth Moreton via fpc-devel 
<fpc-devel@lists.freepascal.org> wrote:

In situations where a nested function has no parameters, is it feasible and 
beneficial to programmatically merge it into the main procedure
What do you mean by "merge"? Like inlining?

Regards,
        Ryan Joseph

_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to