Ante supports a variety of common operators including arithmetic operators, logical operators, assignment operators, among others. The following is a quick run down on the purpose of each operator proceeded by a table of associativity and precedence for each.
- Subtraction (binary), Negation (unary)
< Less than
> Greather than
<= Less than or equal
>= Greater than or equal
= Is equal to, structural equality
!= Not equal to
is Is exactly equal to, referential equality
and Logical and, short-circuiting
or Logical or, short-circuiting
not Logical not
A note on
If two values contain the same values, for example if two
tuples contained the same elements within, they are structurally equal.
If we had two pointers to two separate structurally equal tuples those
pointers would be equal as well. The pointers would not be the same value
however. If one were to mutate the contents of its tuple the other tuple
would not necessarily change unless they point to the same value. If two
pointers point to the same value then they are referentially equal, and
is the other because they point to the same value.
let a = new (5, "five") let b = new (5, "five") let c = a a = b //=> true a = c //=> true a is b //=> false a is c //=> true
:= Assigns a value to a variable
<binop>= Assigns a value to a variable after performing
the operation on the previous value and the expression. ex.
mut a = 3 a += 4 //a is now 7
Bitwise operations are implemented as library functions.
import Bitwise band 3 6 //=> 2 bxor 3 6 //=> 5 bor 3 6 //=> 7 bnot 0 //=> -1 //sl and sr are shift left and shift right respectively. sl 1 3 //=> 8 //sr is arithmetic if its first operand is unsigned, //and logical otherwise. lsr and asr are available as well. sr 8 3 //=> 1
in Test if a value is in a collection
.. Range, inclusive
# Subscript, array/collection access
. Field accessor
|> Applies a value to a function on the rhs
<| Applies a value to a function on the lhs
new Allocates and stores a value
@ Pointer dereference
|Operator||Unary or Binary||Associativity||Precedence|