[fpc-devel] Local procedures as procedural parameter

Michael Van Canneyt michael at freepascal.org
Mon Mar 14 09:45:17 CET 2005



On Mon, 14 Mar 2005, Adriaan van Os wrote:

> 7. Consider the following program:
>
> 	program func;
>
> 	type tfun = function( x: real): real;
>
> 	procedure iso_fun( function f( x: real): real);
> 	begin
> 	end;
>
> 	procedure typ_fun( pf: tfun);
> 	begin
> 	end;
>
> 	procedure somefun;
>
> 		function f( x: real): real;
> 		begin
> 		 	f:= x
> 		end;
>
> 	begin
> 		iso_fun( f);
> 		typ_fun( f); {procedural variable can't get nested routiine}
> 	end;
>
> 	begin
> 	end.

1. What happens if f would use a variable from somefun, and f is called
    when somefun is no longer executed ?

2. I see no difference whatsoever between typ_fun and iso_fun, except
    the use of an extra type, which, in my opinion, does not change
    anything to the usage or code of these functions. If one is allowed,
    the other should be allowed as well.

Michael.




More information about the fpc-devel mailing list