When arguments are passed to a called module, they are passed by reference (i.e. a called module's parameter is made to refer the argument, and no copy is made). This is in contrast to launched-module parameters, and makes for the only case when a static-array reference is not index padded by VTS. When a static array is passed to a called module, the called module's parameter is made to refer to the entire static array, and not just to one particular array element. Consequently, a called module can change the elements of a static-array argument, and any changes will appear outside of the module.
Similarly, when a dynamic array is passed to a called module, the array pointer is not copied to the module parameter, but rather the called module's parameter is made to refer to the array pointer (think of a pointer to a pointer). In this way, a called module can change not only the elements in, but also the size and dimensions of, a dynamic-array argument, and any changes will appear outside of the module.
The following code demonstrates passing arrays to a called module:
[
X Module;
ADynamicArray;
AStaticArray[3];
]
Init [
If 1 Main;
[
ADynamicArray = New(3);
]
]
Main [
X(ADynamicArray);
{ X\Parm refers to ADynamicArray (a pointer) }
X(ADynamicArray[2]);
{ X\Parm refers to ADynamicArray[2]}
X(AStaticArray);
{ X\Parm refers to the entire AStaticArray array }
X(AStaticArray[1]);
{ X\Parm refers to AStaticArray[1] }
]
<
X
(
Parm;
)
Main [
]
>