[fpc-devel] Delphi anonymous methods

Alexander Klenin klenin at gmail.com
Mon Mar 4 12:37:50 CET 2013


On Mon, Mar 4, 2013 at 10:35 PM, Martin <lazarus at mfriebe.de> wrote:
> On 04/03/2013 06:06, Boian Mitov wrote:
>>
>> 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.
>
>
> All fine and good. But all that can be done with a *named* closure too

Also, Boian, I appreciate your enthusiasm very much, but please read
this thread from the start --
the implementation details you mention are extensively described in
the documents linked
from the first message.


-- 
Alexander S. Klenin



More information about the fpc-devel mailing list