General-Usage Types
This page is still under construction!
Abstract also has some other primitive types that aren't just numbers. Some of them exists to create some abstractions with complex collections of numerical values or create type encapsulation.
Booleans
This feature is still not implemented!
Booleans are types that can only represent the binary values true
or false
.
These two values are extremely important to handle conditionals or hold simple
states without messing the values.
Alias | Size | Implementation |
---|---|---|
bool | 1-bit | Std.Types.Boolean |
let bool cake = false
if (cake) Std.Console.writeln("Yummy!")
else Std.Console.writeln("The cake is a lie!")
The cake is a lie!
Strings
This feature is still not implemented!
A string is a data structure that is able to store text data. A string can be
used to store and reproduce text characters easily.
In Abstract, every string is encoded in UTF-8, with characters varying from 1-4
bytes in length.
Alias | Size | Implementation |
---|---|---|
string | variable (content is heap/statically-allocated) | Std.Types.String |
let string mySpeek = "Hello, World!"
Std.Console.writeln(mySpeek)
mySpeek = "Goodbie, World!"
Std.Console.writeln(mySpeek)
Hello, World!
Goodbie, World!
Chars
This feature is still not implemented!
Chars are data structures made to hold a single text character. Chars value can
either be set or assigned manually with a character value or it can be set by
getting a character from an index of a string.
As every string in Abstract is UTF-8, every character have the same length as a i32
in memory, being able to hold every possible character of the Unicode char set.
Keep in mind that some unicode characters may use more than one character to be stored,
e.g. "🇧🇷" = '🇧' + '🇷'
.
The Char struct cannot store that characters and instead need to be used with another
Char value.
Chars are be castable from integers lower than 32 bits e.g. u8
, i7
or u32
and castable to any integer.
Alias | Size | Implementation |
---|---|---|
char | 32 bits | Std.Types.Character |
to declarate a Char data type, use char
:
const string myString = "Hello, World!"
let char myChar = 'U'
myChar = myString[7]
Std.Console.writeln(myChar as byte) # '87'
Range
This feature is still not implemented!
Ranges are types with a special syntax and are used widelly though the language. They can be representd as:
<start>..<finish>:<step>
And some values can be implicited, like:
.. 10 # from 0 to 10
.. 10 : 8 # from 0 to 10 in steps of 8
5 .. # from 5 to MAXINT
5 .. : 14 # from 0 to MAXINT in steps of 14
To iterate though a range, get a instance of the range iterator:
from Std.Console import
const myRange = 0..20 : 2
var iterator = myRange.iterator()
var uptr i
while (iterator.reachEnd()) : (i = iterator.next()) {
writeln(i)
}
Void
This feature is still not implemented!
Void is not a concrete type and it is used to indicate that a value is not returned.
void
NoReturn
This feature is still not implemented!
NoReturn is not a concrete type and it is used to indicate that a function do not returns.
noreturn