It may be a good idea to analyze the current Delphi implementation.
In essence the anonymous method expands to a class and interface.
The interface Execute method has the parameters of the anonymous function. and the corresponding interface has the Execute method. The class contains all the variables that are captured from the current context, and the constructor of the class does the capture. The class is reference counted trough the interface, and is disposed when all references are released. There are some interesting side effects and benefits from the implementation, and there are fear number of articles about that on the web.

With best regards,
Boian Mitov

-------------------------------------------------------
Mitov Software
www.mitov.com
-------------------------------------------------------
-----Original Message----- From: Alexander Klenin
Sent: Sunday, March 03, 2013 9:57 PM
To: FPC developers' list
Subject: Re: [fpc-devel] Delphi anonymous methods

On Mon, Mar 4, 2013 at 2:38 PM, Martin <laza...@mfriebe.de> wrote:


Nevertheless, I agree what the implementation plan can be detailed even further:
1) Anonymous procedures *without* closures -- basically, just another
syntax for nested procedures.
 This is an important step for several reasons:
....
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to