Ryan Joseph
2018-11-15 08:46:19 UTC
Is passing nested procs outside of the calling scope relying on undefined behavior? It doesn’t seem like this should be allowed.
===========================
{$modeswitch nestedprocvars}
program test;
type
TCallback = procedure (i: integer) is nested;
function DoTest: TCallback;
var
context: integer = 0;
procedure Process(x: integer);
begin
context += x;
writeln(x,' ',context);
end;
begin
result := @Process;
end;
var
c: TCallback;
begin
c := DoTest(20);
c(1);
end.
Regards,
Ryan Joseph
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
http://l
===========================
{$modeswitch nestedprocvars}
program test;
type
TCallback = procedure (i: integer) is nested;
function DoTest: TCallback;
var
context: integer = 0;
procedure Process(x: integer);
begin
context += x;
writeln(x,' ',context);
end;
begin
result := @Process;
end;
var
c: TCallback;
begin
c := DoTest(20);
c(1);
end.
Regards,
Ryan Joseph
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
http://l