t3x.org / t3x / t3x-manual / 26.html
 
T3X - A Minimum Procedural Language
Version 8.1.5, Online Edition
Copyright(C) 1996-2004
Nils M Holm
 
Previous:
2.5.1 Signed and Unsigned Values
TOC | Index | Back Next:
2.6.1 Procedure Calls and Subscripts

2.6 Expressions

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:

  1. Postfix operators bind strongest.
  2. The less operands an operator has, the stronger it binds
  3. The ascending order of precedence for binary operators is as follows: disjunction (1), conjunction (2), equational (3), relational (4), bit (5), sum (6), and term (7) operators

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
leftA op B op C (A op B) op C
rightA 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