operators |
Discworld efun help |
operators |
These are the operators availailable in LPC. They are listed in the
order or precedence (low priority first):
expr1 , expr2 Evaluate 'expr1' and then 'expr2'. The returned value is
the result of 'expr2'. The returned value of 'expr1' is thrown
away.
var = expr Evaluate 'expr', and assign the value to 'var'. The new value
of 'var' is the result.
var += expr Assign the value of 'expr' + 'var' to 'var'. This is
equivalente to "var = var + expr".
var -= expr Similar to '+=' above.
var &= expr
var |= expr
var ^= expr
var <<= expr
var >>= expr
var *= expr
var %= expr
var /= expr
expr1 || expr2 The result is true if 'expr1' or 'expr2' is true. 'expr2' is
not evaluated if 'expr1' was true.
expr1 && expr2 The result is true i 'expr1' and 'expr2' is true. 'expr2' is
not evaluated if 'expr1' was false.
expr1 | expr2 The result is the bitwise or of 'expr1' and 'expr2'.
expr1 ^ expr2 The result is the bitwise xor of 'expr1' and 'expr2'.
expr1 & expr2 The result is the bitwise and of 'expr1' and 'expr2'.
expr1 == expr2 Compare values. Valid for strings and numbers.
expr1 != expr1 Compare values. Valid for strings and numbers.
expr1 > expr2 Valid for strings and numbers.
expr1 >= expr2 Valid for strings and numbers.
expr1 < expr2 Valid for strings and numbers.
expr1 <= expr2 Valid for strings and numbers.
expr1 << expr2 Shift 'expr1' left 'expr2' bits.
expr1 >> expr2 Shift 'expr1' right 'expr2' bits.
expr1 + expr2 Add 'expr1' and 'expr2'. If numbers, then arithmetic addition
is used. If one of the expressions are a string, then that
string is concatenated with the other value.
expr1 - expr2 Subtract 'expr2' from 'expr1'. Only valid for numeric values.
expr1 * expr2 Multiply 'expr1' with 'expr2'.
expr1 % expr2 The modulo operator of numeric arguments.
expr1 / expr2 Integer division.
++ var Icrement the value of variable 'var', and return the new
value.
-- var Decrement the value of variable 'var', and return the new
value.
- var Compute the negative value of 'var'.
! var Compute the logical 'not' of an integer.
~ var The boolean 'not' of an integer.
var++ Increment the value of variable 'var', and return the old
value.
var-- Decrement the value of variable 'var', and return the old
value.
expr1[expr2] The array given by 'expr1' is indexed by 'expr2'.
expr1->name(...) 'expr1' gives either an object or a string which is converted
to an object, and calls the function 'name' in this object.