-
Notifications
You must be signed in to change notification settings - Fork 25
Language Reference
Leonardo Laguna Ruiz edited this page Feb 27, 2017
·
12 revisions
// Line Comment
/* Block Comment */
/* /* Nested Comment */ */
// Unit (or empty value)
val u : unit = ();
// Integers
val x : int = 0;
val y : int = 1;
val z : int = 3942;
// Real (floating or fixed point)
val a : real = 1.0;
val b : real = 2.0;
val c : real = 3.1416;
// Booleans
val k : bool = true;
val l : bool = false;
Numbers without the decimal dot are integers and cannot be mixed with real numbers.
Operators require that both arguments are the same type.
- Addition : '+'
- Subtraction : '-'
- Multiplication : '*'
- Division : '/'
- Modulo : '%'
e.g.
val x = 1 + 2;
val z = -1.0; // Unary minus
val y = 3.8 * 56.0;
- And : '&&'
- Or : '||'
- Not : 'not' // 'not' is a function
e.g.
val l = not(1.0 > 3.0) || false;
- Equal : '=='
- Unequal : '<>'
- Less than : '<'
- Greater than : '>'
- Less than Eq. : '<='
- Greater than Eq. : '>='
If expressions require an else
branch.
val x = if y > 0.0 then 3.0 else 4.0;
val x,y,z = 1,2,3;
val (x,y,z) : (int,int,int) = 1,2,3;
val point : (real,real,real) = 0.0, 1.0, 2.0;
Array types are in the form array(type,size)
e.g. array(int,3)
it's an array of 3 integers.
val x = [1,2,4];
val y : array(real,3) = [1.0, 2.0, 4.0];
Function calls are special in Vult since they create implicit context. These context can be anonymous or named.
val x = foo(); // anonymous context
val y = bob:foo(); // context with name 'bob'
val z = bob:foo(); // this call is performed in the context 'bob'