LVALUE = EXPR
LVALUE must be an expression that evaluates to a memory location where the expression value can be stored, e.g. a variable. An assignment evaluates to the same value and type of the data stored. The right hand expression is always computed before the left.
LVALUE OP EXPR
In this case the expression is combined with the LVALUE using on of the available operators: += -= *= /= = &= |= ^= <<= >>= >>>=
FUNCTION(ARGS)
Functions can only be called in expressions. Functions with no return value (void) can only be called when no data is expected, e.g. alone on a line.
intf @a = clss();
convert the intf handle to a clss handle clss @b = cast<clss>(a);
Object handles can be converted to other object handles with the cast operator. If the cast is valid, i.e. the true object implements the class or interface being requested, the operator returns a valid handle. If the cast is not valid, the cast returns a null handle.
Primitive types can also be converted using the cast operator, but there is also an alternative syntax.
int a = 1; float b = float(a)/2;
In most cases an explicit cast is not necessary for primitive types, however, as the compiler is usually able to do an implicit cast to the correct type.
The compiler is also able to use declared object constructors when performing implicit conversions. For example, if you have an object type that can be constructed with an integer parameter, you will be able to pass integer expressions to functions that expect that object type, as the compiler will automatically construct the object for you. Note, however that this conversion cannot be done implicitly if the function expects a reference argument.
operator | description | left hand | right hand | result |
+ | unary positive | NUM | NUM | |
- | unary negative | NUM | NUM | |
+ | addition | NUM | NUM | NUM |
- | subtraction | NUM | NUM | NUM |
* | multiplication | NUM | NUM | NUM |
/ | division | NUM | NUM | NUM |
% | modulos | NUM | NUM | NUM |
Plus and minus can be used as unary operators as well. NUM can be exchanged for any numeric type, e.g. int
or float
. Both terms of the dual operations will be implicitly converted to have the same type. The result is always the same type as the original terms. One exception is unary negative which is not available for uint
.
operator | description | left hand | right hand | result |
~ | bitwise complement | NUM | NUM | |
& | bitwise and | NUM | NUM | NUM |
| | bitwise or | NUM | NUM | NUM |
^ | bitwise xor | NUM | NUM | NUM |
<< | left shift | NUM | NUM | NUM |
>> | right shift | NUM | NUM | NUM |
>>> | arithmetic right shift | NUM | NUM | NUM |
All except ~
are dual operators.
operator | description | left hand | right hand | result |
not | logical not | bool | bool | |
and | logical and | bool | bool | bool |
or | logical or | bool | bool | bool |
xor | logical exclusive or | bool | bool | bool |
Boolean operators only evaluate necessary terms. For example in expression a and b
, b
is only evaluated if a
is true
.
operator | description | left hand | right hand | result |
== | equal | value | value | bool |
!= | not equal | value | value | bool |
< | less than | value | value | bool |
> | greater than | value | value | bool |
<= | less or equal | value | value | bool |
>= | greater or equal | value | value | bool |
++ --
These operators can be placed either before or after an lvalue to increment (or decrement) its value either before or after the value is used in the expression. The value is always incremented or decremented with 1.
[EXPR]
This operator can only be used if the application has supports it.
EXPR ? A : B
If expression is true A is executed, if not then B is executed instead.
OBJ . MEMBER
OBJ must be an expression resulting in a data type that have members. MEMBER is the name of the member to be accessed. This member may or may not be read only.
@ VAR
VAR is an object that allows its handle to be taken. The handle can then be assigned to a handle variable of the same type, or compared against another handle, or null
.