Expressions
A base expression consists of a primitive type along with an optional role specifier.
For instance the expression "Hello"@Alice
evaluates to a value of type String@Alice
.
If no role is specified, then the value of the resulting value will exist at all roles in the current scope.
Thus, in the example below, x
will have type String@[A,B,C]
.
func@(A,B,C) main() {
let x = "hello";
}
Binary operations
The following binary operations are supported:
+
addition,-
subtraction,/
division,%
modulo.==
equality,!=
negated equality.<
less than,<=
less than or equal,>
greater than,>=
greater than or equal.&&
logical and,||
logical or
Binary operations are only allowed if the types of the two values have intersecting roles.
This means that Int@A + Int@A
is not allowed, but Int@A + Int@B
is not.
When carrying out operations on shared types, the result will exist at the intersection of the roles.
let x: Int@[A,B,C] = 5;
let y: Int@[B,C,D] = 7;
let sum: Int@[C,D] = x + y;
Other expressions
- Await async value
await x
- Struct construction
- Function calling
myFunction()
- List construction
[1,2,3]
- List indexing
list[i]
- Communication
A->B value
Closure construction
See closures for more details.
let x = func@(A,B) (input: Int@A) Int@B {
return await A->B input;
};
Field access
Some types have fields that can be accessed as value.field
.
This includes:
- Fields of structures
- Methods of interfaces
- The
.length
field of lists