operators, precedence, and associativity

Langur uses the following, in order of descending precedence.

category operators associativityL/R
function call
not grouping
() leftL
index
not array literals
[] leftL
prefix -
exponent ^ ^/ rightR
product x / \
rem mod
leftL
sum + - leftL
range .. to leftL
concatenate ~ (tilde) leftL
less/greater < <=
> >=
<? <=?
>? >=?
leftL
logical negation not
not?
equality == !=
==? !=?
leftL
logical and and
and?
leftL
logical equality xor leq
xor?
leq?
leftL
logical or or or? leftL
assignment = rightR

See the numbers page for math operator descriptions.

combination operators

The concatenate operator and the infix math and logical operators may be used with the equal sign as combination operators. For example, writing .x += 1 is the same as writing .x = .x + 1.

database operators

Normal operators treat null as an ordinary value (don't favor propogating null). Testing null == null returns true and null == false returns false.

Operators ending with ? are database operators. For these, if either side is null, the result is null. Testing null ==? anything returns null.

short-circuiting operators

The and and or operators are short-circuiting.

Database operators are short-circuiting in a different manner (only if the left value is null). This includes the and? and or? operators.

NaN comparison

Testing NaN == NaN returns false, and NaN ==? null returns null. The isNaN() function may be helpful here.

composite comparisons

Items of the same type (arrays, hashes, or ranges) may be directly compared for equality or inequality.

These comparisons are not affected by the NaN issue. That is, NaN within composite items compare as being the same. So, NaN != NaN, but [NaN] == [NaN].

Whereas 1 == 1.0, within a composite comparison, this is not true, so that [1] != [1.0].