[fpc-pascal] Are there any drawbacks to "reference to"?
Hairy Pixels
genericptr at gmail.com
Mon Jun 20 15:32:44 CEST 2022
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
More information about the fpc-pascal
mailing list