On Mon, 14 Mar 2005 [EMAIL PROTECTED] wrote:

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 ?

Yes this is a problem, but it can be solved by not allowing an iso style procedure parameter to be stored in a variable. It should only be allowed to be passed to another procedure or to be called.

In fact standard pascal does not allow procedure variables, only procedure
parameters (note the difference). I suppose the above problem is the
reason.

Then I think standard pascal is very handicapped indeed.


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.

No, and at present there is no difference in generated code.

Which means that the above example IS a problem.

Michael.

_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to