As of version 3.3.1, CommandHelper supports traditional operators, in addition to still allowing the pure functional approach. (In fact, the operation functions are still used internally regardless). This allows you to write more readable code, by using more standard symbols instead of only functions.
Consider the following pre-3.3.1 code:
if(and(equals(@var, 3), lte(2, @var2)), msg('Something'))
This is fairly hard to read, and could quickly get even more complicated and harder to read the more conditions you add. Instead, you can use infix notation now, using standard C/Java operators. The same code as above, converted to the infix notation looks like:
if(@var == 3 && 2 <= @var2, msg('Something'))
Besides being slightly shorter, it's easier for a human to read. "@var equals 3 and 2 is less than or equal to @var2" as opposed to "and equals @var 3 lte 2 @var2". You could have also been more explicit with parenthesis, as loose parentheticals are no longer restricted.
if((@var == 3) && (2 <= @var2), msg('Something'))
The following operators are supported, and their order of operations is from top to bottom. Note that all operators are simply converted to the functional notation, so if your code is incorrect, the errors you get will specify function names.
|Postfix||++ --||postinc/postdec||This is only considered postfix when it comes after an identifier: @i++|
|Unary||! ++ --||not/inc/dec||These are unary operators, they only operate on one identifier|
|Multiplicative||* / %||multiply/divide/mod|
|Additive||+ - .||add/subtract/concat||If a minus or plus sign is used to denote the sign of a number, it is handled slightly differently, for instance, 2 + -1 does not use any subtraction|
|Relational||< > <= >=||lt/gt/lte/gte|
|Equality||== != === !==||equals/nequals/sequals/snequals||There is no operational equivalent for equals_ic|
|Assignment||= += -= *= /= .=||assign|| There is no single functional equivalent except for = per se, @var += 1 is equivalent to assign(@var, add(@var, 1)), etc. += uses |
Note the lack of bitwise operators, which are usually standard in other languages. These are not provided, because the operators are infrequently used, and may be used for other operations in the future. The functions themselves,
bit_or() still exist, so no functionality has been removed.
Also of note, auto-concatenation always takes lowest priority to all other operations.