index

Expressions

Assignments

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.

Compound assignments

LVALUE OP EXPR

In this case the expression is combined with the LVALUE using on of the available operators: += -= *= /= %= &= |= ^= <<= >>= >>>=

Function call

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.

Type conversions

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.

Math operators

operatordescriptionleft handright handresult
+ 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 either int, uint, or float. Both terms of the dual operations must 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.

Bitwise operators

operator description left hand right hand result
~ bitwise complement   bitsbits
& bitwise and bitsbitsbits
| bitwise or bitsbitsbits
^ bitwise xor bitsbitsbits
<< left shift bitsuintbits
>> right shift bitsuintbits
>>>arithmetic right shiftbitsuintbits

All except ~ are dual operators. The shift operators take and integer value on the right hand. All other values are of bits type.

Logic operators

operator description left hand right hand result
notlogical not   boolbool
andlogical and boolboolbool
or logical or boolboolbool
xorlogical exclusive orboolboolbool

Boolean operators only evaluate necessary terms. For example in expression a and b, b is only evaluated if a is true.

Comparison operators

operator descriptionleft handright handresult
== equal VAL VAL bool
!= not equal VAL VAL bool
< less than CMP CMP bool
> greater than CMP CMP bool
<=less or equal CMP CMP bool
>=greater or equal CMP CMP bool

VAL can be exchanged for bool, bits, int, uint, float, or bstr. CMP can only be exchanged for int, uint, float, or bstr. Both the left hand and right hand values must have the same type.

Increment operators

++ --

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.

Indexing operator

[EXPR]

This operator can only be used if the application has supports it.

Conditional expression

EXPR ? A : B

If expression is true A is executed, if not then B is executed instead.

Member access

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.

Handle-of

@ 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.

top