Function Expressions
Previous Topic  Next Topic 

A function expression is where a function is called and the return value of the function is used as the result of the expression.


For example, if a function is defined that returns the product of two numbers:


func product(a,b)

    return (a*b)

end


Then this function can be used in an expression wherever an rvalue is valid:


a=product(2,3);    // a is set to 6

b=product(2,2)*product(product(2,2),2);    // b is set to 32


A function expression is also an expression that can be said to have side effects since it can alter the values of variables.