|
| Previous: 2.5.1 Signed and Unsigned Values | TOC | Index | Back | Next: 2.6.1 Procedure Calls and Subscripts |
In expressions, operators may be used to modify or combine factors in various ways. Most operators may be applied to any kind of operand, even if the resulting operation may not evaluate to any meaningful value.
There are different kinds of operators and like procedures, they are classified by the number of their arguments (which are called operands in this context). There are unary (single-argument) prefix operators, binary (two-argument) infix operators, and there is one ternary (three-argument) operator and one variadic (variable-argument) postfix operator.
Operators may also be classified by their precedences. The higher the precedence of an operator is, the stronger it binds its operands. For example, the term operators (product, quotient, remainder) bind stronger than the sum operators (sum, difference). Therefore,
a * b + c * d
is equal to
(a*b) + (c*d)
Like in math expressions, parentheses may be used to override these default bindings. The precedence rules are simple in T3X:
The precedence rules in 3. are similar to the rules used in the evaluation of algebraic math expressions.
Another property of an operator is its associativity. For example, an operator associates to the left, if a sequence of identical operations is evaluated from the left to the right:
| Associativity | Expression | Meaning |
|---|---|---|
| left | A op B op C | (A op B) op C |
| right | A op B op C | A op (B op C) |
In T3X, all binary operations with the sole exception of :: are left-associative. The byte operator is right-associative. Unary operators are always right-associative.
In the remainder of this section, all availabe operators will be explained. The appearance is ordered by descending precedence.
| Previous: 2.5.1 Signed and Unsigned Values | TOC | Index | Back | Next: 2.6.1 Procedure Calls and Subscripts |