|
|||||
Functions: result types | |||||
Prerequisite Concepts | Related Syntax |
The result-type is generally one of the keywords switch
, counter
, or stream
. It can also be used to indicate when an external function is an external output function or an external source function. When result type is given, it always precedes the function name.
Every called function must eventually return to its caller (unless it does a halt
or contains a terminating error). The explicit way of returning from a function is to use a return
action, which can appear anywhere within a function definition. The form of the return
action depends on the result type defined for that function, which is specified at the start of the function definition.
The result type of a function determines from where the function can be called in an OmniMark program:
counter
-returning function can be called in a numeric expression.
switch
-returning function can be called in a test.
stream
-returning function can be called in a string expression.
Generally, value-returning functions can be called from anywhere that an operator returning the same type can be called.
If a function has no return type, then the function call can only be used in the place of an action.
Note that a function does not require a return
action if it does not return a value. The function will simply return when there are no more actions to execute.
Prerequisite Concepts Functions |
Related Syntax define function return |
---- |