|The Hyper Programming Language|
|home||language reference||compiler||hyper on launchpad|
This page documents the built-in class types. Arrays are classes too, but they are not described here. All types except for pointers are classes.
The fact that the built-in types are classes means that they have the same rights as regular user defined classes. They are not considered more important than other classes when doing overload resolution. In this way Hyper differs from C++. The only "privilege" a built-in primitive type has, is that is represented by a reserved keyword while user-defined class types are not.
All built-in types except for object are sealed classes, which means that you cannot inherit from them. As the root of the inheritance hierarchy, object is an abstract class, so you cannot instantiate it on its own. It can only be used as a class to inherit from.
Built-in types can by divided roughly into two groups: numeric types and non-numeric types. The numeric types can be further split up into the integral types and the non-integral types. The non-integral types are the three floating-point types. The integral types can be split up again into the signed and unsigned integral types. Integral types can also be viewed as specified size types and unspecified size types.
|Numeric||Integral||Specified size||Unspecified size|
|Signed||int16, int32, int64||int|
|Unsigned||byte, nat16, nat32, nat64||nat|
|Non-numeric||bool, char, object, string|
The class object is the root of the inheritance hierarchy. The built-in types are derived from it, and any user defined class that doesn't specify a base class to inherit from is also derived from it implicitly. So any type can be seen as an object.
Object class reference
The bool type is a boolean type, which means it can only hold the values true and false.
Bool class reference
A byte is an unsigned 8 bit number. It can contain any integral number in the range zero to 255, inclusive.
Byte class reference
char represents an Unicode "code point". So it is different from what languages as C++ and Java do (in C++ a char is 8 bits and Java has a 16-bit char). A char is meant to be able to contain any existing character. As 16 bits are not enough, char will need to be 32 bits wide. Storing text is not supposed to be done by storing arrays of chars, so the bigger space requirement is not an issue.
Char class reference
A string is a sequence of characters, and is used for text. The characters it contains are of type char, so the string can be used to hold any text. Strings will not be simple arrays of char; they will use an encoding such as UTF-8 in order to save space.
String class reference
These types are fixed-size signed integers. An int16 is 16 bits, an int32 is 32 bits and an int64 is 64 bits.
An int is a signed integer which has a size that depends on the machine the code is compiled for. So for a program compiled for a 32-bit machine, it is 32 bits, while for a 64-bit machine it will be 64 bits. An int is at least 32 bits wide, so any byte, int16, nat16 or int32 can be converted to an int. Conversion from an int to an integer type with fixed size and the other way around is platform dependent. So the usage of such a conversion makes that code not portable. It is recommended to collect all non-portable code inside a few source files and keep the majority of the other source files portable; this will ease the porting of your program to another platform.
Int class reference
These types are fixed-size unsigned integers. So an nat16 is 16 bits, an nat32 is 32 bits, and an nat64 is 64 bits.
A nat is actually the unsigned version of an int. The same conversion rules apply. It is at least 32 bits, so any byte, nat16 or nat32 will fit in it. The size of a nat is equal to the size of an int.
In case you were wondering, ‘nat’ stands for ‘natural number’. This refers to the set of nonnegative integers 0, 1, 2, 3, ...
Nat class reference
These types are floating-point types. single and double should behave like the IEEE standard floating-point types with the same name. So single is a 32 bit type, and double is a 64 bit type.
real is a special one. This type represents the widest possible hardware floating point type. This means that the size of this type is machine architecture dependent. For example, on an Intel x86 architecture it will be an 80 bit type. real must always be at least 64 bits, so that any value of type double will fit in it. For an architecture that doesn't provide a hardware floating point type that is suitable to be used as a real, a software emulation type should be used.