Skip to content

Syntax & Variables

Tulpar supports the following data types:

TypeDescriptionExample
intInteger numbersint x = 42;
floatFloating-point numbersfloat pi = 3.14;
strUTF-8 stringsstr name = "Hamza";
boolBoolean valuesbool flag = true;
arrayMixed-type arraysarray mix = [1, "text", 3.14];
arrayIntType-safe integer arraysarrayInt nums = [1, 2, 3];
arrayFloatType-safe float arraysarrayFloat vals = [1.5, 2.5];
arrayStrType-safe string arraysarrayStr names = ["Ali", "Veli"];
arrayBoolType-safe boolean arraysarrayBool flags = [true, false];
arrayJsonJSON-like objectsarrayJson obj = {"key": "value"};

Variables are declared with their type:

Variables

Integers can be written in four bases. Underscores are not allowed — keep large numbers readable with comments instead.

FormExampleDecimal value
Decimal255255
Hexadecimal0xFF255
Octal0o755493
Binary0b101010

Floating-point numbers accept the standard C-style forms:

float pi = 3.14;
float small = 1.0e-5;
float large = 6.02e23;

Integers above i64 range trigger a compile-time warning and are clamped to INT64_MAX (2^63 − 1).

Operators are listed from lowest to highest precedence. Operators on the same row have equal precedence and associate left-to-right unless noted.

TierOperatorsAssociativity
1 (lowest)= += -= *= /=right
2||left
3&&left
4== !=left
5< > <= >=left
6+ - (binary)left
7* / %left
8- (unary), !right
9 (highest)++ -- (postfix), () call, [] index, . memberleft

Use parentheses when in doubt — they read better than relying on precedence rules across more than one tier:

// Both compile, but the parenthesised form is clearer.
int score = a + b * c; // = a + (b * c)
int score = a + (b * c);

Tulpar supports single-line and multi-line comments:

Comments