ERROR RETURN
</programlisting>
-<para>(An example of its use is shown near the end of subsection 3.8.3).</para>
+<para>(An example of its use is shown near the end of <xref
+linkend='internal_and_external'/>).</para>
<para>In order to use it in a function evaluation, the last
(right-most) argument of the function must be the label of a statement
<para>There are two main types of functions: The <emphasis> internal
</emphasis> function and the <emphasis> external </emphasis> function.
Since these are quite similar in many ways, that part of the
-description which is specific to external functions
-<!-- beginpage -->
+description which is specific to external functions <!-- beginpage -->
will be given in <xref linkend='external_functions'/>, that which is
specific to internal functions in <xref
linkend='internal_functions'/>, and that which is common to both types
-will follow in subsection 3.8.3. Throughout this section a
-single-valued function will be called a "function", and a function
-with multiple outputs and/or multiple exits will be called a
-"procedure". For the purposes of this manual a recursive function is
-one whose definition contains calls for the function being defined --
-or calls for functions which ultimately call the one being defined.
-Recursive functions have the same structure as other functions
-although, in general, they will include statements of the type
-described in <xref linkend='list_statements'/>, and certain
+will follow in subsection <xref linkend='internal_and_external'/>.
+Throughout this section a single-valued function will be called a
+"function", and a function with multiple outputs and/or multiple exits
+will be called a "procedure". For the purposes of this manual a
+recursive function is one whose definition contains calls for the
+function being defined -- or calls for functions which ultimately call
+the one being defined. Recursive functions have the same structure as
+other functions although, in general, they will include statements of
+the type described in <xref linkend='list_statements'/>, and certain
considerations should be borne in mind when constructing such
functions. These considerations arise from the fact that <emphasis>
names </emphasis>, instead of values, are used as function arguments.
<para>As indicated above, X, Y, and Z, as they occur here, are dummy
<!-- beginpage -->
-variables, and (X, Y, Z) is the dummy variable list.</para>
+variables, and (X, Y, Z) is the dummy variable list. The current value
+of T, however, will be obtained and used each time the value of the
+function is needed. An example of theuse of the function so defined
+would be:</para>
+
+<para role='centered'>
+A = 1.-SUMSQ. (U, V + 3, W) .P..5
+</para>
+
+<para>Only nonsubscripted names of variables (either individual or array) or
+names of functions (without arguments) may appear in the dummy
+variable list. For this type of function definition no END OF
+FUNCTION statement is required. In the user of the function is an
+expression, the arguments may be any expressions that agree in mode
+with the corresponding argument in the declaration.</para>
+
+<para>In the example:</para>
+
+<para role='centered'>
+INTERNAL FUNCTION POLY. (N, X, FN.) = FN. (J*X).P.N - X/XBAR
+</para>
+
+<para>which might be used in the statement</para>
+
+<para role='centered'>
+BETA ZQ = POLY.(M + 1, Y, SIN.) + POLY.(M -1, Z, COS.)
+</para>
+
+<para>it is understood that if N is in the integer mode, then so are Y and
+Z. Both M and N would have had to be declarted to be in the integer
+mode, of course. Similarly, the values of SIN. and COS. must be the
+same mode as the values of FN. Moreover in the use of functions this
+mode correspondence cannot be checked by the translator.</para>
+
+<para>The function POLY. has as one of its arguments the name of a function.
+In the statement BETA the function used in the first term to the right
+of the "=" sign is SIN. and in the second term COS.. Hence statement
+BETA is then equivalent to:</para>
+
+<para role='centered'>
+ZQ = SIN.(J * Y).P.(M + 1) - Y/XBAR + COS.(J*Z).P.(M-1)-Z/XBAR.
+</para>
+
</sect3>
+<sect3 id='internal_and_external'><title>Internal and External Functions</title>
+
+<para>Each function definition (except single statement definitions
+described in <xref linkend='internal_functions'/>) may define any
+number of functions and/or any number of procedures. Within one
+function definition all functions and procedurews defined must use
+exactly the same set of arguments. In other words, the functions
+CPADD.(X,Y,A,B)and CPMPY.(X,Y,A,B) may be defined, if desired, by one
+definition, but the functions SIN.(X) and ARCTAN.(X.Y) would require
+separate definitions.
+<!-- beginpage -->
+Similarly, the procedures RXSUB. and ADAMS. could be defined by the
+same definition if they have the same outputs, say Z and W, and the
+same input parameters, say X, Y, T, and N. However, if they did not
+have exactly the same outputs and the same inputs, they would require
+separate declarations.</para>
+
+<para>In the <emphasis>use</emphasis> of a function (i.e., the
+<emphasis> call </emphasis> for it) the arguments may be constants,
+variables, or expressions. However, if one of the arguments appears
+to the left of an "=" sign in a substitution statement in the defining
+program it is not meaningful to use a constant or an expression for
+that argument in the call. As mentioned earlier, the arguments in the
+call for a function cannot be checked for correspondence in mode and
+number to arguments in the definition.</para>
+
+<para>The general form of all function definition programs is as
+follows:</para>
+
+<programlisting>
+INTERNAL FUNCTION (X)
+ENTRY TO COS.
+...
+...
+...
+ENTRY TO SIN.
+...
+...
+...
+FUNCTION RETURN ALPHA + J - 3
+ENTRY TO TAN.
+...
+...
+...
+FUNCTION RETURN BETA/K5 - 4 * D
+END OF FUNCTION
+</programlisting>
+
+<para>The first statement (INTERNAL FUNCTION (X)) is a function
+declaration (i.e., <emphasis>declares</emphasis> that the following
+statements define a function). If this is defining an external
+function, the declaration would be EXTERNAL FUNCTION (X). Following
+the words INTERNAL (or EXTERNAL) FUNCTION is the dummy variable list
+((X) in this example). The END OF FUNCTION declaration is the last
+statement in the function definition program. (In an external
+<!-- beginpage -->
+function definition this is also the last statement in the program.)
+An entry must provided for each function being defined, but several
+functions may share any number of FUNCTION RETURN statements. An
+entry statement merely marks a point of entry, and does not effect the
+sequence of computation in any way. The expression after the word
+"RETURN" indicates that on this return the value of the function is to
+be the value of that expression.</para>
<!-- MORE GOES HERE -->
+</sect3>
</sect2>
</sect1>
</chapter>
</mediaobject>
<!-- beginpage -->
-<para><emphasis>Program:</emphasis>It is assumed here that f
+<para><emphasis>Program:</emphasis> It is assumed here that f
(referred to as F. in the program) will be defined as an internal
function.)</para>