[fpc-devel] Delphi anonymous methods

Vasiliy Kevroletin kevroletin at gmail.com
Sun Mar 3 06:08:10 CET 2013


> Do you have any ideas how and why such behaviour implemented ?
>
Now I can answer my question myself. *Local variables of anonymous 
method are located on stack*.

This assumption is based on 2 points:

1.

assignment to local variable of anonymous function

x := 10;

will become this

mov [ebp - $04], $a

=== full example ===

begin
   Call( procedure
         var x: Integer;
         begin
           x := 10;          { mov [ebp - $04], $a }
           Writeln(x);
         end );
end.

===

2. example

https://gist.github.com/vkevroletin/5069653
output for example is in first comment after code.

Vasiliy

P.S.

In last email I pasted one javascript example 3 times accidentally.
I was writing from vrt277 at gmail.com before because emails from my main 
mailbox wasn't delivered to mail list.



More information about the fpc-devel mailing list