This page lists every syntactic operator in Dana.
Arithmetic
| Syntax | Effect |
| i++ | increment value of i, return incremented value |
| i-- | decrement value of i, return decremented value |
| a + b | add value of a to b, return result |
| a - b | substract value of b from a, return result |
| a * b | multiply value of a by b, return result |
| a / b | divide value of a by b, return result |
| a % b | divide value of a by b, return remainder |
| a += b | add value of b to a, assigning result to a |
| a -= b | substract value of b from a, assigning result to a |
| a *= b | multiply value of a by value of b, assigning result to a |
| a /= b | divide value of a by b, assigning result to a |
| a %= b | divide value of a by b, assigning remainder to a |
Logic
| Syntax | Effect |
| ~ a | bitwise logical not on value of a, return the result |
| a & b | bitwise logical and on values of a and b, return the result |
| a | b | bitwise logical or on values of a and b, return the result |
| a ^ b | bitwise logical xor on values of a and b, return the result |
| a && b | return true if a and b are true, not executing b if a is false |
| a || b | return true if a or b are true, not executing b if a is true |
| !a | boolean not on value of a, return the result |
| a << b | left-shift value of a by number of bits given by b, return result |
| a >> b | right-shift value of a by number of bits given by b, return result |
Assignment
| Syntax | Effect |
| a = b | assign value of b to a |
| a =[] b | copy array cells of b into array cells of a |
Comparison
| Syntax | Effect |
| a == b | return true if the value of a is equal to the value of b |
| a != b | return true if the value of a is not equal to the value of b |
| a === b | return true if a refers to the same memory as b |
| a !== b | return true if a does not refer to the same memory as b |
| a > b | return true if value of a is greater than the value of b |
| a >= b | return true if value of a is greater than or equal to the value of b |
| a < b | return true if value of a is less than the value of b |
| a <= b | return true if value of a is less than or equal to the value of b |
Control flow
| Syntax | Effect |
| if (<boolean>) { } | conditionally execute a block of code, if the boolean parameter is true |
| if (<boolean>) { } else { } | conditionally execute a block of code, if the boolean parameter is true, otherwise execute the 'else' block of code |
| if (<boolean>) { } else if (<boolean>) { } | conditionally execute a block of code, if the boolean parameter is true, otherwise execute the 'else if' block of code, if the second boolean is true |
| while (<boolean>) { } | repeatedly execute a block of code, for as long as the boolean parameter is true |
| for (<initialiser> ; <boolean> ; <increment>) { } | execute the <initialiser> statement once, then repeatedly execute a block of code, for as long as the boolean parameter is true, executing the <increment> statement at the end of each repeat |
| break | jump out of the most closely nested loop |
Arrays
| Syntax | Effect |
| x[index] | access an array cell by index, where the first array cell is at index zero |
| x.arrayLength | return the number of cells in the array x |
Construction
| Syntax | Effect |
| new DataType() | construct a new data instance of type DataType |
| new DataType(firstField, secondField) | construct a new data instance of type DataType, assigning its first two fields to the given values |
| new DataType(firstField, otherField = x) | construct a new data instance of type DataType, assigning its first field to the given value, and a named field to a given value |
| new ArrayType[size] | construct a new array instance of type ArrayType, with the number of cells given by size |
| new ArrayType | construct a new array instance of type ArrayType, with the cells copied from the content parameter(s) |
| new ObjectType() | construct a new object instance of interface type ObjectType |
| new ObjectType(paramValue1, paramValue2) | construct a new object instance of interface type ObjectType, passing in values to the constructor's parameters |
| new ObjectType(paramValue1, myParam = x) | construct a new object instance of interface type ObjectType, passing in a value to a constructor's mandatory parameter, and a value to an optional named parameter |
| new Data() from X | construct a new data instance of the type indicated in the lang.Type instance X |
| new ObjectType() from X | construct a new object instance of interface type ObjectType, from the component referred to the by the lang.IDC instance X |
Concurrency
| Syntax | Effect |
| this.thread | access the lang.Thread instance of the current thread |
| mutex(x) { } | enforce sequential access to a block of code, where x can be any data instance |
| asynch::function() | launch a local function as a new thread, returning a lang.Thread instance |
Event model
| Syntax | Effect |
| sinkevent Handler(x) | route events emitted by object x to the event handler Handler |
| stopevent Handler(x) | stop receiving events from object x to the event handler Handler |
| emitevent eventType(x) | emit an event of the given event type, with the optional data instance parameter x |
Memory management
| Syntax | Effect |
| clone x | make a copy of the data or array instance x |
| reclone x | make a copy of the data or array instance x, recursively copying any referenced array or data instances |
| delink x | set all references to null, recursively, in the data or array instance x |
Status checks
| Syntax | Effect |
| isset x | check if an optional function parameter x was set to anything at invocation time |
| implements x | check if the current component is the implementer of the object x |
Reflection
| Syntax | Effect |
| Type.[fieldName] | return the integer index of the given field name into the given type's fields |
| a:.b | return the value of the field index b of data instance a |
| a:.b() | invoke the function index b on the object instance a |
| typeof(t) | return the lang.Type instance reflecting the type of t |
System calls
| Syntax | Effect |
| dana.sub(a, start, end) | gain a reference to sub-array of array a, starting from index start and ending at index end (inclusive) |
| dana.serial(x) | gain a reference to the memory region of data or array instance x, as a byte array |
| dana.getIDC() | get the IDC reference of the Dana runtime |