To define a procedure recursively, refer to it within the procedure body by the pseudo-identifier $$.
If the procedure is assigned to an identifier NAME using this syntax:
procedure NAME([~]FORMAL_IDFIER, ..., [~]FORMAL_IDFIER) STATEMENTS end procedure;
instead of:
NAME := procedure([~]FORMAL_IDFIER, ..., [~]FORMAL_IDFIER) STATEMENTS end procedure;
then the procedure may also be referred to by its own name within the procedure body.
The parser understands these two forms to be the same, except that any textual reference to NAME inside STATEMENTS is changed to the pseudo-identifier $$.
A definition of a procedure called Results, taking two integers, can begin in either of these ways:Results := procedure(r, f) OR procedure Results(r, f)
Within the procedure body, the statement
$$(3, 7);
means a call to Results. If the procedure is being defined in the second way, then
Results(3, 7);
is also permissible.
[Next] [Prev] [_____] [Left] [Up] [Index] [Root]