[fpc-pascal] Forward declarations

Anton Shepelev anton.txt at gmail.com
Thu Dec 22 22:04:34 CET 2011


Timothy Groves:

> Can anyone think of a situation in which you would
> *have* to use  forward  declared  functions?   I'm
> trying  to come up with an example for such for my
> book, and I am drawing a blank.

Pascal User Manual and Report says:

    Procecure (function) identifiers may be used be-
    fore  the  procedure  (funtion)  declaration  if
    there is a forward declaration.  Forward  decla-
    rations  are  necessary to allow mutually recur-
    sive procedures and functions that are not nest-
    ed.  The form is as follows:

        procedure Q(X:T); Forward;
        procedure P(Y:T);
        begin
          Q(A)
        end;

        procedure Q;
          { parameters and result types are not repeated }
        begin
          P(B)
        end;

But  are  "mutually  recursive  procedures and func-
tions" necessary?

Anton



More information about the fpc-pascal mailing list