From the purely formal point of view, all Refal Plus functions are assumed to take a single
argument and to return a single result. In many cases, however, the structure of a function's
argument and result is known in advance. For example, the function
The restrictions imposed on the argument and result of a function are specified by the
declaration of the function. For example, the declaration of the function
In general, the declaration of a function
where
All input and output formats must be "hard", which means that any subexpression of a format
may contain no more that one ve-variable at the top level of parentheses. For example, the
format
All inputs to, and results of, a function must have the structure specified by the function's
declaration. The function's declaration must precede all references to the function made in
the result expressions appearing in the program. If the function is defined in the program,
its declaration must explicitly appear in the program prior to the definition. Otherwise, if
the function is defined in other module, its declaration must be imported into the program by
a directive
When the program is being compiled, the compiler verifies that the argument expressions in
the calls to the function are consistent with the input format of the function. For example,
consider the result expression
The inner call is obviously correct. But, to check the outer call, we have to make use of the
information about the structure of the results returned by the function
is regarded as illegal, because the argument of the outer call consists of three symbols,
despite the input format of the function
Thus, specifying the input and output formats enables many errors to be found at compile time, rather than at run time.
From the purely formal point of view, all Refal Plus functions are assumed to take a single
argument and to return a single result. In many cases, however, the structure of a function's
argument and result is known in advance. For example, the function
The restrictions imposed on the argument and result of a function are specified by the
declaration of the function. For example, the declaration of the function
In general, the declaration of a function
where
All input and output formats must be "hard", which means that any subexpression of a format
may contain no more that one ve-variable at the top level of parentheses. For example, the
format
All inputs to, and results of, a function must have the structure specified by the function's
declaration. The function's declaration must precede all references to the function made in
the result expressions appearing in the program. If the function is defined in the program,
its declaration must explicitly appear in the program prior to the definition. Otherwise, if
the function is defined in other module, its declaration must be imported into the program by
a directive
When the program is being compiled, the compiler verifies that the argument expressions in
the calls to the function are consistent with the input format of the function. For example,
consider the result expression
The inner call is obviously correct. But, to check the outer call, we have to make use of the
information about the structure of the results returned by the function
is regarded as illegal, because the argument of the outer call consists of three symbols,
despite the input format of the function
Thus, specifying the input and output formats enables many errors to be found at compile time, rather than at run time.