<Operators>


Expressions

The precedences are listed in decreasing precedence order. For instance, multiplication binds stronger than addition, which means that "1+2*3" is understood as "1+(2*3)"


Operator Description Associativity

(__) parentheses N/A
(type) __ type conversion N/A
|__| vector size N/A
|__| relation size N/A
|__| string size N/A
({__}) expression-statement N/A

__[__] string indexing (between 0 and |s|-1) N/A
__[__] vector indexing (between 0 and |v|-1) N/A
__[__..__] substring (s[a..b] is from a to b-1) N/A
__[__..__] subvector (v[a..b] is from a to b-1) N/A
__.__ tuple member reference left

!__ logical NOT N/A
-__ unary minus N/A
+__ unary plus N/A
++__ pre increment N/A
--__ pre decrement N/A
__++ post increment N/A
__-- post decrement N/A

__<[__] document plug N/A

__*__ multiplication left
__/__ integer division left
__/__ float division left
__%__ modulo left

__\+(__) tuple project N/A
__\-(__) tuple project complement N/A

__+__ addition left
__+__ string concatenation left
__+__ vector concatenation left
__-__ substraction left

__<<__ left tuple overwrite left
__>>__ right tuple overwrite left

__<__ less than N/A
__>__ greater than N/A
__<=__ less than or equal N/A
__>=__ greater than or equal N/A

__==__ equal left
__!=__ not equal left

__&&__ lazy logical AND left

__||__ lazy logical OR left

__?__:__ conditional operator right

__=__ assignment right
__+=__ addition, then assignment right
__-=__ substraction, then assignment right
__*=__ multiplication, then assignment right
__/=__ division, then assignment right
__%=__ modulo, then assignment right
__=<[__] plug, then assign right

lazy
means that if the result of an expression can be determined by evaluating the left operand only, then the right operand is not evaluated. This makes a difference when the right operand has side-effects or does not terminate.
left
means that the given operator is left-associative. For instance, "x+y+z" will be parsed as "(x+y)+z".
right
means that the given operator is right-associative. For instance, "x=y=z" will be parsed as "x=(y=z)".


bigwig@brics.dk
Last updated: November 2, 2001
Valid HTML 4.01!