[fpc-pascal] nested procedure as parameter question

Bruce Bauman bruce.bauman at andesaservices.com
Thu Apr 15 19:51:46 CEST 2010


I am porting a large amount of existing Pascal code (MetaWare) to Free
Pascal. Unfortunately, this code makes extensive use of nested
procedures, and the nested procedures often reference variables in the
enclosing scope.

I know that I can't pass the nested routine by address to another
procedure; I get errors like the following:

intjob4_intday.pas(400,47) Error: Incompatible type for arg no. 3: Got
"<address of local procedure(StdStr04);Register>", expected "<procedure
variable type of procedure(StdStr04);Register>"

Can I get around this restriction by inlining the procedure which is
being passed the nested procedure as an argument?

For example, let's say the A is the enclosing procedure, B is the nested
procedure, and B is being passed as a parameter to C.

Procedure A;
    Procedure B;

Begin
    C(@B);
End;

Can I inline procedure C? Will this work? (My initial test with fpc
2.4.0 suggests it doesn't work).

-- Bruce
CONFIDENTIALITY NOTICE: This e-mail is confidential and intended
solely for the use of the individual or entity to which it is addressed.  If
you are not the intended recipient, be advised that you have received 
this email in error and that any use, dissemination, forwarding, printing 
or copying of this e-mail is strictly prohibited. If you received this e-mail
in error, please delete it from your computer and contact the sender.




More information about the fpc-pascal mailing list