[fpc-pascal] Local procedures as actual procedure parameter in macpas mode

Alberto Narduzzi albertonarduzzi at yahoo.com
Tue Aug 24 22:52:35 CEST 2010


Jonas,

> No. He's using MacPas mode in FPC 2.5.1. In that mode, nested procedural variables are supported (and also in ISO mode, and also in all other syntax modes if you add {$modeswitch nestedprocvars}). The error message was caused by a compiler bug.
> 
> This declares a regular procvar, while the original declaration declares a nested procvar. Declaring it as a separate type would have to be done like this:
> 
> Type TMyProc Procedure(var y:myObject) is nested;
> 
> Note that you can assign both global and nested/local procedures to a nested procedural variable (and also call both using such a procvar). And be careful when using a separate "is nested" type, because then you can construct code that calls a nested procedural variable outside the scope where it is valid (which will result in undefined behaviour).


thanks for the explanation, I didn't know all this. I don't use nested 
procedures as parameters, so from the error message I just assumed they 
weren't allowed.

Cheers, A.


-- 
Alberto Narduzzi
ANSware Ltd.



More information about the fpc-pascal mailing list