9.1 Overview

An expression is a combination of operands and operators. If there is at least one operand and one operator we speak of an expression. Hollywood needs to evaluate expressions before it can pass their result to a function. An expression can be constant or variable, depending on whether it contains variables or not. For example, 5 + 3 is an expression. The operands are 5 and 3 and the operator is +. -1 is also an expression because we have one operand and one operator. Usually operators are binary which means that they require two operands but there are exceptions: For example, the negation operator (-) is unary and therefore requires only one operand.

You can use parentheses in expressions to tell Hollywood what shall be evaluated first. In the following line

 
a = (3 + 4) * 5

Hollywood will first add 3 and 4 and then multiply the result of the addition by 5. If you did not include the parentheses in the code above, Hollywood would first evaluate 4 * 5 and then add 3 to it because the multiplication operator (*) has a higher priority than the addition operator (+). See Operator priorities for details.


Show TOC