[fpc-devel] nestedprocvar questions
david at scootersoftware.com
Tue Jul 31 19:04:28 CEST 2012
Some questions about 'nestedprocvars' mode switch
We have a simplified version of the nested procedure calling
demonstrated in tests/test/tmaclocalprocparam3d.pp. It looks more or
tnestedprocvar = function(AArg: string): boolean;
procedure p1(AArg: string; pp: tnestedprocvar);
if pp(AArg) then
function r(AArg: string): boolean;
Result := true;
p1('test string', @r);
Notice that it is $MODE DELPHI, that the proc var is a function, and that we do not access any external variables in the nested function.
There seems to be an interaction between $MODE DELPHI and the 'is nested' construct. I.e. I cannot put the 'is nested' after the tnestedprocvar type and do the function passing with '@r'. If I do the compiler complains about getting a pointer (@r) when it was expecting a function (..): boolean is nested. So either I remove the'@' and just pass 'r' or I do not include the 'is nested'.
Is this correct?
This code is being compiled both with Delphi compiler and with FPC. Delphi handles the nesting with no problem and with no 'is nested' directive.
Should nestedprocvar be included automatically with $MODE DELPHI for compatibility?
If we set up our code as above can we expect the compiler to be consistent in parameter set up for the next while?
If we set up our code as above (with no 'is nested') would it be safe to include access of an external variable (internal to procedure q) to the nested function?
More information about the fpc-devel