Skip to content

Types

Data types in tpl-lang are the main mechanism for managing memory and data.
Most of them have size, range and analogue in C (because of LLVM backend)

Here's the table of avaible types in compiler:

TypeSize (bits)DescriptionC analogueRange
int888 bits signed integer typechar0 to 255
int161616 bits signed integer typeshort-32 768 to 32 767
int323232 bits signed integer typeint-2 147 483 648 to 2 147 483 647
int646464 bits signed integer typelong-9 223 372 036 854 775 808 to 9 223 372 036 854 775 807
bool1Boolean type (true - 1, false - 0)bool0 to 1
char1Char typechar0 to 255
str8String typechar*-
void1Void type (just null value)void-
array-Array of any typeint var[], char var[], bool var[]...-
fn-Function/Closures type--
auto-Automatically defines the type--
pointer-Points to special memory address--

Examples

Integers:

tpl-lang
int8 a = 5;
int16 b = 123;
int32 c = 5555;
int64 d = 123123;

String:

tpl-lang
str name = "Jason";
str surname = "Statham";

Boolean:

tpl-lang
bool is_true = true;
bool is_false = false;

bool it_works = true;
bool any_errors = false;

Void:

tpl-lang
void variable;
void another_variable = some_void_func();
void null_val = null;

Arrays:

tpl-lang
int8[3] a = [1, 2, 3];
auto b = [3, 2, 1];

Pointers:

tpl-lang
int32* ptr;
*ptr = 5;


int32 variable = 10;
int32* var_ptr = &variable;

*var_ptr = 3;