Passing variables by reference
By default, lvalues in ScriptEase are passed to functions by value (that is, the function cannot alter the lvalue) . But if a variable is declared in a function with the "&" symbol then it is passed by reference. I a function alters a pass-by-reference (i.e. &argument) variable, then the variable passed as an argument by the calling routine is altered also, if it is an lvalue. So instead of the following C code which uses address and pointer operators:
main()
{
CQuadrupleInPlace(&i);
...
}
void CQuadrupleInPlace(int *j)
{
*j += 4;
}
a ScriptEase conversion could be:
function main()
{
...
QuadrupleInPlace(i);
...
}
function QuadrupleInPlace(&j)
{
j += 4;
}
The following calls to QuadrupleInPlace() are valid in ScriptEase, but the values passed as arguments are not changed after QuadrupleInPlace() is called. Why? None of the arguments being passed are lvalues.
QuadrupleInPlace(8);
QuadrupleInPlace(i+1);
QuadrupleInPlace(8+1);
Pointer operator * and address operator &