The language only supports a 64-bit signed integer (int64) data type. This is the data type for every variable, parameter and function return value. This means that you don’t need to check for type incompatibilities. |
-
Every program starts its execution in a function called
main
with zero parameters. It’s an error if the program does not contain a function with this name. -
Any variable defined outside a function is a global variable. The scope of a global variable is the body of all the functions in the program, even those defined before the variable itself.
-
Function names and global variables exist in different namespaces. This means that you can have a global variable with the same name as a function and vice versa.
-
It’s an error to define two global variables with the same name.
-
It’s an error to define two functions with the same name.
-
A function definition is visible from the body of all the functions in a program, even from itself. Thus, functions can call themselves recursively directly or indirectly.
-
In every function call the number of arguments must be the same as the number of parameters contained in the corresponding function definition.
-
The following names are part of the initial namespace for functions and constitute int64’s API (the number after the slash symbol (/) is the arity of the given function):
-
printi
/1 -
printc
/1 -
prints
/1 -
println
/0 -
readi
/0 -
reads
/0 -
new
/1 -
size
/1 -
add
/2 -
get
/2 -
set
/3
-
-
Each function has its own independent namespace for its local names. This means that parameter and local variable names have to be unique inside the body of each function. It’s valid to have a parameter or local variable name with the same name as a global variable. In that case the local name shadows the global variable.
-
It’s an error to refer to a variable, parameter or function not in scope in the current namespace.
-
The
break
andcontinue
statements can only be used insidewhile
,do
-while
, orfor
statements. -
Values of numerical literals should be within their specified ranges according to their radix (see section 2.5.2. of the int64 specification).
-
Any other semantic error not mentioned here is a runtime error and will be dealt with in the code generation phase.