Can anyone explain why this works? TProc is a normal function pointer so how
did it capture gVar? My understanding is that only nested proc vars could do
this.
{$mode objfpc}
{$modeswitch anonymousfunctions}
program anonymous_functions;
type
TProc = procedure;
procedure Call(proc: TProc);
begin
proc;
end;
var
gVar: integer;
begin
Call(procedure
begin
writeln(gVar);
end);
end.
Regards,
Ryan Joseph
_______________________________________________
fpc-pascal maillist - [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal