Deep Dive Into Ballerina Runtime - Types II
Table of Content⌗
Background⌗
A lot of this is not required. We explored various parts of ballerina native compiler through number of posts and following is essential to understand what is going on with this one. So please read it.
Integer implementation⌗
most C family progammers are familiar with size of a type. For instance, an int
is exactly 4 bytes in intel architecture. However, there are other int types that are either higher or lower in size, int8, int16 and int64 are 1, 2, and 8 bytes respectively.
Ints can also be divided based on two’s compliment. There are unsigned ints as well as signeed ints, in which the former cannot represent negative numbers of the number line.
Ballerina implements this through IntSubtype
custom type.
public type IntSubtype readonly & Range[];
So it is essentially an array of another custom type called Range
.
// Ranges are inclusive
// Require min <= max
public type Range readonly & record {|
int min;
int max;
|};