The TEMPORARY function returns a temporary copy of a variable, and sets the original variable to “undefined”. This function can be used to conserve memory when performing operations on large arrays, as it avoids making a new copy of results that are only temporary. In general, the TEMPORARY routine can be used to advantage whenever a variable containing an array on the left hand side of an assignment statement is also referenced on the right hand side.
Assume the variable A is a large array of integers. The statement:
A = A + 1
creates a new array for the result of the addition, places the sum into the new array, assigns it to A, and then frees the old allocation of A. Total storage required is twice the size of A. The statement:
A = TEMPORARY(A) + 1
requires no additional space.
Note: If the operation performed on Variable requires that Variable be converted to another data type, there is no benefit to using TEMPORARY. For instance, if the array A in the above example contained byte data rather than integer data, the array would have to be converted to integer type before the addition could be performed. In such a case, memory could not be re-used.
Result = TEMPORARY(Variable)
Returns a copy of a specified variable.
The variable to be referenced and deleted.