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 vrt...@gmail.com before because emails from my main mailbox wasn't delivered to mail list.
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to