Types are dynamically assigned to variables; you can not specify a type for a variable. Any variable can contain one of the following types of value:
An object has fields that can be assigned any type of value. You create an object like this:
myObject = object();
This creates an empty object. You can set/get fields of the object using:
myObject.someField = 1337; myObject["anotherField"] = "This is cool!";
An array is an actual array in memory that is used when you need plain data for native calls. You can create an array like this:
myArray = array<8>(128);
This creates an 8-bit array with a length of 128. You can access each field of the array using the array subscript [] operator:
myArray[0] = 25; someNumber = myArray[0] * 2;
Accessing a cell of an array on results in a number. Only numbers can be assigned to array cells.
is either true or false. Equality (==, !=), logical (&&, ||) and relational (>, <, >=, <=) expressions result in a value of type bool.
a numeric literal can be denoted in the following ways:
25 // integer value 43.210 // decimal value 0xDEADBEEF // hexadecimal value 0b10010110 // binary value
string literals are denoted using quotes " or primes '. See the strings page for more details.
using a concurrent expression results in a value of this type. This type of value is used for the join expression to retrieve the value of a concurrently executed statement.
when an variable name starts with a dollar $ sign, a special handling is done. Accessing the value of such a variable returns the value of the environment variable (retrieved via the getenv function) with that name.
Like this you can easily retrieve values from the environment:
compiler = $CXX; IO.println("The compiler is '{compiler}'");
Setting such a variable is equal to a call to the putenv C function (or SetEnvironmentVariable on Windows).
a variable can be assigned a project. When declaring a project with a name, there is actually a variable in the global scope with that name which holds the project value.
a variable can be assigned a task. When declaring a task with a name, there is a variable in the declaration scope with that name which holds the task value.
task someTask { /* ... */ } // the variable "someTask" now contains the task value: someTask(); // assigning the variable copies the reference to the task: myVariable = someTask; myVariable();
To check if an object is of one of the types, use the typecheck expression. This expression looks returns either true or false. On the left-hand-side there can be any expression, on the right-hand-side one of the above types.
something = object(); if(something is object) { IO.println("It's an object!"); }