### Operators

The following table summarizes all 11l operators in order of precedence from highest to lowest:
 x.y module:f a[x] f(x) x-- x++ Member access Module function or variable access Subscript Function call Postfix decrement Postfix increment ^ Power operator (right to left associative) -x +x !x (-)x --x ++x &x Unary minus Unary plus Logical NOT Bitwise NOT (rationale: {… Operator (-) complements operator XOR (+) and has the following properties: a(-)b = NOT (a XOR b) NOT a = 0(-)a = (-)a a(-)(-)b = a(+)b a(+)(-)b = a(-)b (-)(-)a = a However, binary operator (-) is not supported in hardware and used extremely rare, therefore 11l includes only unary operator (-), which corresponds to bitwise NOT. }) Prefix decrement Prefix increment Address-of x * y x / y x I/ y x % y Multiplication Division Integer division {…note that `-5 // 2 = -3` in Python whereas `-5 I/ 2 = -2` in 11l, but this is merely because of performance considerations, and if you know efficient implementation of Python integer division, please write at the forum} Remainder x + y x - y Addition Subtraction x << y x >> y Bitwise left shift Bitwise right shift x [&] y Bitwise AND (rationale: {… [&] looks similar to AND gate: }) x (+) y Bitwise XOR (rationale: {… Symbols (+) look like symbol ⊕, which is used in Boolean algebra for exclusive or operation: . And although ⊕ is used more often for single-bit values, in Wikipedia it is sometimes used for pointers and for arrays of bytes. [Besides, usage of ^ for this operation I consider a bad idea (at least this is confusing for novices).] }) x [|] y Bitwise OR (rationale: {… Symbol | looks like 1 and  looks similar to OR gate: }) x < y, x <= y x > y, x >= y Comparison operators x..y, x.flags & Control::F_DISABLED) { ... } if (c->flags & Render::F_CAST_SHADOWS) { // this is wrong, but will be correctly compiled in C++! ... } } ``` 11l solution: span.keyword {color: #0000FF; font-weight: bold;} span.identifier {color: #00009F;} span.string-literal {color: #800000;} span.numeric-literal {color: #008000;} span.constant {color: #008000;} span.comment {color: #808080;} ```T Control T.flags flags DISABLED or: T Control T Flags Bool DISABLED Flags flags F some_func(Control c) I c.flags.DISABLED ... ``` }, so the decision was made to discourage from such usage of bitwise AND operator at all. Sometimes bitwise AND is used as a modulo (`%`) operation of powers of 2, but if the second operand is constant, then operator `%` should be used instead (`x [&] y = x % (y + 1)`). If operator `%` works for negative numbers like in Python (i.e. e.g. `-1 % 4 = 3`), then expression `x % (y + 1)` will be compiled to bitwise AND. }) x | y Logical OR x ? y Null coalescing () -> expr x -> expr (x, y) -> expr Lambda expression arr1 [+] arr2 Array concatenation (rationale: {… Because arrays are defined using square brackets: `[1, 2, ...]`. As this operation is quite expensive, it has dedicated operator. }) x = ... x += ... -= *= /= I/= %= >>= <<= ^= [+]= [&]= [|]= (+)= ‘’= Assignments (right to left associative)