Context Block Operator that provides a better alternative to call chaining. See Context Blocks.
Conversion Operators
Operator
Description
->
Convert. Convert a value to a different type - a->BType converts value a to type BType. Convert automatically works with primitives. To work with objects and compounds, define method to->Type (e.g. method to->String) and those conversion methods will be automatically invoked when the operator is used.
?->
Conditional conversion. If the left-hand context is null, the result is the default value (0/null/false) of the target type.
->(as Type)
Cast-As. When called on reference obj of any type, obj->(as SomeType) produces a reference of type SomeType if obj instanceOf SomeType; otherwise it produces null.
Indexed Access (AKA Element Access; list[i] = x). An indexed getobj[i] resolves to obj.get(i). An indexed setobj[i] = x resolves to obj.set(i,x).
list[i,j] resolves to list.get(i,j) and list[i,j] = k resolves to list.set(i,j,k).
When used with an enum that has the [bitflags] attribute, EnumType[A,B] is equivalent to EnumType.A | EnumType.B, etcetera.
Logical Operators
Operator
Description
and
Logical And
or
Logical Or
xor
Logical Exclusive Or
not
Logical Not (unary operator - not a)
?
Logicalize (unary operator - a?). Converts any type of value into a Logical. Non-zero primitives logicalize to true. For compounds, a logicalize operator method (operator?) is called if it exists, or else a Logical conversion method (method to->Logical) must exist and that is called. Reference types are handled the same as compounds except that if neither an operator method nor a conversion method exists then any non-null reference becomes true.
Range Operators
Operator
Description
..
Up-To.
..<
Up-To-Less-Than.
..>
Down-To-Greater-Than.
downTo
Down-To.
Reference Comparison Operators
Operator
Description
is
a is b returns true if a and b both reference the same object.
is not
a is not b returns true if a and b reference different objects.
Stepper Operators
Operator
Description
++
Increment (++a is Pre-increment; a++ is Post-increment)
--
Decrement (--a is Pre-decrement; a-- is Post-decrement)
String-Indexed Access Operator
Operator
Description
//
table//key is shorthand for table["key"]. table//key = value is shorthand for table["key"] = value.
Type Evaluation Operators
Operator
Description
instanceOf not instanceOf
a instanceOf T returns true if object or type a is type T or is a direct or indirect subclass of type T. a not instanceOf T is the logical inverse.
isType not isType
a isType T returns true if object or type a is exactly type T. This is useful for evaluating template parameters and defined constants for code branching purposes. a not isType T is the logical inverse.
$hasMethod
Compile-time meta-command $hasMethod<<context,"method_name">> evaluates to true if the given context has any method with the given name.
$isCompound
$isCompound<<Type>> evaluates to true if Type is a compound type. Note that enums count as compound types.
$isEnum
$isEnum<<Type>> evaluates to true if Type is an enum type.
$isPrimitive
$isPrimitive<<Type>> evaluates to true if Type is a primitive type.
$isReference
$isReference<<Type>> evaluates to true if Type is a reference type (object or aspect).
Operator Precedence
The operators below are listed from lowest to highest precedence.
Assignment operators (=, +=, ...) are statement-level operators, not expression-level operators. They do not result in a value, cannot be nested in a larger expression, and are not listed here.
Operator
Description
||
Operand Or (Conditional Operand)
&&
Operand And (Conditional Operand)
xor
Logical Exclusive Or
or
Logical Or
and
Logical And
==!=<<=>>=
Comparison
isis notinstanceOfisType
Reference Comparison and Type Evaluation
....<..>downTo
Range Operators
~
Bitwise Xor (Bitwise Exclusive Or)
|
Bitwise Or
&
Bitwise And
+-
Add and Subtract
:<<::>>::>>>:
Bit Shifts (note that Rogue bit shifts have higher precedence than Add & Subtract, unlike C-family languages)