[fpc-devel] Delphi anonymous methods

Martin lazarus at mfriebe.de
Mon Mar 4 12:21:03 CET 2013


On 04/03/2013 05:00, Boian Mitov wrote:
> One thing for sure, I probably will very much never need to declare 
> TThread inherited classes. I can use a single anonymous method for 
> that, thanks to the ability of the anonymous method to capture local 
> and member variables.
> This is something not doable with closure as it has fixed number of 
> parameters ;-) .

Afaik, that is exactly what a closure is. To capture the 
scope/environment of the surrounding code (including the local variables 
of the procedure in which it is declared.

An anonymous method just skips the name, and allows to declare it in-line.

Delphi may not offer them individually. I do not know... But this is not 
about what Delphi offers.



More information about the fpc-devel mailing list