[fpc-pascal] nested procedure as parameter question
Bruce Bauman
bruce.bauman at andesaservices.com
Thu Apr 15 20:00:32 CEST 2010
I did try it, and I got the same error message from the compiler. However, I can't be sure if the compiler didn't allow inlining for some other reason.
BTW, it would be nice if there were some equivalent to gcc's pragma inline_only(?) which says that the procedure MUST be inlined (or an error is generated).
-- Bruce
-----Original Message-----
From: fpc-pascal-bounces at lists.freepascal.org [mailto:fpc-pascal-bounces at lists.freepascal.org] On Behalf Of Flávio Etrusco
Sent: Thursday, April 15, 2010 1:57 PM
To: FPC-Pascal users discussions
Subject: Re: [fpc-pascal] nested procedure as parameter question
On Thu, Apr 15, 2010 at 2:51 PM, Bruce Bauman
<bruce.bauman at andesaservices.com> wrote:
> 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
I don't think this will work, but why didn't you try it? It would be
very nice if the nested procedures which don't access outside vars
were allowed to be used as non-local procedure...
Flávio
_______________________________________________
fpc-pascal maillist - fpc-pascal at lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
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