Re: [fpc-pascal] nested procedure as parameter question
Bruce Bauman 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: See http://bugs.freepascal.org/view.php?id=15925 Regards, Adriaan van Os ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] nested procedure as parameter question
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. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] nested procedure as parameter question
On Thu, Apr 15, 2010 at 2:51 PM, Bruce Bauman bruce.bau...@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@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
RE: [fpc-pascal] nested procedure as parameter question
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-boun...@lists.freepascal.org [mailto:fpc-pascal-boun...@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.bau...@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@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. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal