Introduction to Programming in ATS: | ||
---|---|---|
<<< Previous | Elements of Programming | Next >>> |
The simplest types in ATS are primitive types, which are used to classify primitive values. For instance, we have the primitive types int and double, which classify integers (in a fixed range) and floating point numbers (of double precision), respectively.
In the current implementation of ATS (Anairiats), a program in ATS is first compiled into one in C, which can then be compiled to object code by a compiler for C such as gcc. In the compilation from ATS to C, the type int in ATS is translated to the type of the same name in C. Similarly, the type double in ATS is translated to the type of the same name in C.
There are many other primitive types in ATS, and I will introduce them gradually. Some commonly used primitive types are listed as follows:
bool: This type is for boolean values true and false.
char: This type is translated into the type in C for characters.
schar: This type is translated into the type in C for signed characters.
uchar: This type is translated into the type in C for unsigned characters.
float: This type is translated into the type in C for floating point numbers of single precision.
uint: This type is translated into the type in C for unsigned integers.
lint: This type is translated into the type in C for long integers.
ulint: This type is translated into the type in C for unsigned long integers.
llint: This type is translated into the type in C for long long integers.
ullint: This type is translated into the type in C for unsigned long long integers.
size_t: This type is translated into the type in C of the same name, which is for unsigned integers of certain precision.
string: This type is for strings, and its translation in C is the type void* (for pointers). I will explain this translation elsewhere.
void: This type is for the void value, and its translation in C is the type void (for pointers). It should be noted that the void value is unspecified in ATS. I often say that a function returns no value if it returns the void value, and vice versa.
<<< Previous | Home | Next >>> |
Static Semantics | Up | Tuples and Tuple Types |