Order of Evaluation

There is no guaranteed order for evaluation of parameters on a prototyped call. This fact may be important when using parameters that cause side effects, as the results may not be what you would expect.

A side effect occurs if the processing of the parameter changes:

If a side effect occurs, then, if the parameter is used elsewhere in the parameter list, then the value used for the parameter in one part of the list may not be the same as the value used in another part. For example, consider this call statement.

                CALLP         procA (fld : procB(fld) : fld)

Assume that procA has all value parameters, and procB has a reference parameter. Assume also that fld starts off with the value 3, and that procB modifies fld to be 5, and returns 10. Depending on the order in which the parameters are evaluated, procA will receive either 3, 10, and 5 or possibly, 3, 10, and 3. Or possibly, 5, 10, and 3; or even 5, 10, and 5.

In short, it is important to be aware of the possibility of side effects occurring. In particular, if you are providing an application for third-party use, where the end user may not know the details of some of the procedures, it is important ensure that the values of the passed parameters are the expected ones.



[ Top of Page | Previous Page | Next Page | Contents | Index ]