Expressions
These are words that are reserved by the language for use in expressions, meaning they evaluate into a value, therefore can be assigned to a variable.
Operations
There are some basic operations between types built into solus, and these are accessible with familiar and simple operators that you will recognize from maths or other programming languages. Note: i64 and f64 are automatically converted for basic operations with each other, and the target type is always determined by the type of the left-hand side.
var x = 1 + 2;
val y = 4 / 4;
x = (x * y) / 3.0;self
Self refers to the future storage location of an object during its construction. You can then capture the object in member functions, getting around the need to have the object passed as an argument to its own methods. Self is not defined in other contexts, and can be used as a name for local variables if you so desire.
Example
var x = {
count = 3
call = [self](){ self.count }
};true, false, nil
These represent constants for their respective types, and cannot be overridden or used for names of local variables.
do {}
Executes a block and evaluates to the trailing return of the block. If the block does not have a trailing return, it will evaluate to nil. This is useful for executing code for function arguments, like this:
Example
io.println(do {
var x = 1;
x += 3;
x
});c and a or b
The and/or statements can be used to short circuit, as they evaluate to the last value that was evaluated within them. Therefore, or evaluates to the first truthful value, and and evaluates to the last truthful value.
Example
var x = true;
io.println(x and "true" or "false");Note: You may also use &&/|| instead of and/or respectively.
