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-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to