Subsections

Types

Asterix is a strongly typed language. There are basic types (bool, char, int, and real), and compound types, as described below.

int

A value of type int denotes a signed integer. The minimum and maximum values of an int depends on the implementation, but the maximum is at least 32767, and the minimum at most -32768.

char

A value of type char is in the range '$\backslash$000' to '$\backslash$377'.

real

The range of values of type real is machine and implementation dependent.

bool

A value of type bool is either true or false.

array

type
$\rightarrow$
array of type$_1$

type
$\rightarrow$
string

An array is a sequence of values of a base type, type$_1$. A variable of an array type is a reference to an array, which must be dynamically allocated by a call to the new operator, and destroyed with a delete statement. The size of an array is not part of its type, but must be specified when using the new operator. If the size of the array is $n$, the array can be indexed by a value $0 \leq i < n$. There are no multi-dimensional arrays, but the base type of an array may be an array. This way even non-rectangular data structures can be composed. string is a shorthand for array of char. Unlike C strings, Asterix strings are not terminated by '$\backslash$0'.

The null type

There is an implicit type, the null type. No variables of the null type can be declared, but the null constant is of the null type.

Type compatibility

Two expressions are assignment compatible if and only if one of the following rules holds:

K.G. Langendoen 2010-01-08