[fpc-pascal] Feature Announcement: Function References and Anonymous Functions

Hairy Pixels genericptr at gmail.com
Fri May 27 06:13:49 CEST 2022



> On May 27, 2022, at 2:47 AM, Sven Barth via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:
> 
> Further RTL enhancements like the declaration of TProc<> or the addition of a TThread.Queue() that takes a function reference will come in the near future now that the basics on the compiler side are done. Maybe we can now also tackle ports of libraries like Spring4D and OmniThreadLibrary. There's also the idea to introduce a syntax to control whether symbols are captured by-reference (as currently) or by-value.
> 
> Enjoy!

Huge news, I’m so excited about this. Thank you both.

As discussed over the last years, now that we’ve implemented the anonymous functions part can we consider an optimization for closures that don’t leave the current scope? I explored the possibility of using the existing nested function feature and I think that would work great with the anonymous functions syntax.

The open questions are:

1) How does the compiler know the closure will not leave the scope?
2) The actual implementation, leverage the nested functions which are stacked based objects or change the closure capture object to be a record instead of an interface (much more work I believe).

Regards,
	Ryan Joseph



More information about the fpc-pascal mailing list