[fpc-devel] Closures

Blaise at blaise.ru Blaise at blaise.ru
Wed Dec 9 11:43:11 CET 2015

On 09.03.2015 16:36, Blaise at blaise.ru wrote:
> On 15.01.2012 18:26, Blaise wrote:
>> I have implemented the support for the Delphi-compatible non-generic closures.
> I am ready to commit the improved (and fully compilable) version.

Four years later, here comes (vastly improved) second attempt at a public release: http://hg.blaise.ru/public/fpc .

My plan is to:
1) Collect the initial remarks and fix the most awful bugs and shortcomings that would prevent merging this into the trunk (I am using Hg for this step because I want to be able to seamlessly synchronise with trunk and branch at ease.)
2) When the overall design and implementation are deemed acceptable, correct the remaining coding style issues and push into my branch on the official SVN server.
3) Create a ticket and wait for the merge.

Initial tests: http://hg.blaise.ru/public/fpc-tests .

A) Things that work (at least, expected to -- before the merge):
	* embedding nameless routines into expressions;
	* accessing outer variables/parameters/Selves from such routines and from routines nested in them;
	* new method reference type;
	* structural type equivalence for method references;
	* 100% Delphi-compatible design and implementation, including two crucial points:
		1) closure objects are descendants of TInterfacedObject;
		2) method references are half-hidden interface types.
B) Things that do not work (not planned to be addressed before the merge):
	* accessing outer local-variables/parameters/Selves that are located more than one level higher than the nameless routine;
	* omitting currently mandatory () for invoking method references without arguments;
	* assigning normal routines and methods to method references;
	* support for generics.
C) Future possibilities:
	* special handling for nameless routines that do not capture anything.
May go into A) or B): capturing large parameters by value may have issues -- needs checking.
Known bugs, mostly for A): http://hg.blaise.ru/public/fpc-tests/file/tip/closures/TODO .


More information about the fpc-devel mailing list