|
|||||
Order of evaluation | |||||
Prerequisite Concepts |
The components of OmniMark actions and operators are evaluated in order, from left to right, and the action or operator is performed only after all its components (arguments) have been evaluated.
In particular, this means that the side effects of functions called during the evaluation of an action occur in the lexical order of the function calls in the action.
More particularly, the order of evaluation of the components of an action, operator or function call is as follows:
set
actions and as modifiable and read-only function arguments.
These steps are applied recursively to the component expressions of an action, operator or function call, as those component expressions are evaluated.
The first and third stages are those at which function side effects may occur.
The reason for this order of evaluation is to constrain the places at which checks for non-existent shelf items need be done. Note that a side effect of a function may be to create or delete a shelf item.
In this example:
set counter target item f1 to f2
f1
is called.
f2
is called.
counter target
is selected using the result of f1
as an item number.
f2
.
As a consequence of this left-to-right evaluation, the selected item may not exist prior to the set
(or "set counter
") action, but actually be created by either "f1" or "f2". It could even be removed by "f1" and recreated by "f2".
Note that programming in this style is generally deprecated.
Prerequisite Concepts Arithmetic and comparison operators Functions: argument classes |
---- |