[fpc-devel] Nested function closures
Ryan Joseph
genericptr at gmail.com
Tue Apr 27 21:19:55 CEST 2021
> On Apr 27, 2021, at 12:10 PM, Sven Barth via fpc-devel <fpc-devel at lists.freepascal.org> wrote:
>
>> So as Sven wrote, you would be duplicating effort, needlessly, since it has
>> to work always... If the compiler can decide that the heap interface is not
>> needed and optimize it away: so much the better. But I doubt this will be
>> possible.
>
> In nearly all cases the interface can't be optimized away.
So as you showed it's not as bad as I thought, which is good, however my point was that in my scenario, which I argue is indeed very common, it could be implemented as a "nested anonymous function". My reasons:
1) Nested functions already exist and merely need an anonymous parser to be implemented (as I already did in that branch).
2) The interface is literally 100% useless as the object is never passed outside of the receiver (SortEntities). It will be created and destroyed with absolutely no value to the program whatsoever.
Regards,
Ryan Joseph
More information about the fpc-devel
mailing list