[Next] [Up] [Previous]

The SUBPROGRAM Statement

The statement


declares V to be a variable which, in reality, contains the entry address of a function subprogram, but which is used as the function itself. Thus, . V=%%S(FUN) is used, whereas . W=%S(FUN) is used for a W that is declared ADDRESS (SUBPROGRAM). . V=_CON(W) is also allowed.

So, the function whose address is in V can be used just by using V as a function with a variable identity: . X=V(25.) for example, would provide the natural logarithm of 25 if . V=%%S(_LN((REAL))) was previously executed. Note that V(25) would not work, as implicit type conversion is not possible under such conditions (except in EASY mode).

Inside subprogram headers, the name of the associated type only is used to declare an argument to be of type SUBPROGRAM, since such a declaration does not need to be distinguished from a FUNCTION, or SUBROUTINE statement.

A variable of type SUBPROGRAM (FUNCTION) can be used as the fn-name argument of an OPERATOR statement to allow the function referred to by the variable to be used as an operator.

[Next] [Up] [Previous]