docs

Language guide

Variables

How to declare, reassign, and use variables in kemlang-py.

Declaring a variable

Use aa x che val to declare a new variable. aa means “this”, che means “is”. Types are inferred - you never write them explicitly.

jsk
kem bhai aa name che "Sanket" // string aa age che 25 // integer aa balance che 9.99 // float aa active che bhai chhe // boolean bhai bol name bhai bol age aavjo bhai

Reassigning a variable

Drop the aa to reassign. You cannot reassign a variable that hasn't been declared yet - kemlang-py will throw an error.

jsk
kem bhai aa count che 0 bhai bol count // 0 count che 10 bhai bol count // 10 count che count + 5 bhai bol count // 15 aavjo bhai

All data types

Strings

Text values. Single or double quotes both work. Concatenate with +.

jsk
aa msg1 che "double quotes" aa msg2 che 'single quotes' aa full che msg1 + " and " + msg2 bhai bol full

Integers

Whole numbers, positive or negative.

jsk
aa x che 42 aa y che -7 aa z che 0

Floats

Decimal numbers. Division always returns a float when the result is not whole.

jsk
aa pi che 3.14159 aa rate che -0.5 aa ratio che 10 / 3 // 3.333...

Booleans

bhai chhe and bhai nathi are the boolean literals. true and false are also accepted as aliases.

jsk
aa isOn che bhai chhe // true aa isOff che bhai nathi // false aa same che true // also works

String + number concatenation

If either side of + is a string, the other side is automatically converted. You never need to cast manually.

jsk
kem bhai aa score che 87 bhai bol "Score: " + score // Score: 87 bhai bol score + " points" // 87 points aavjo bhai

Scope

Variables declared inside a block (jo, farvu) are scoped to that block. They are not accessible outside it.

jsk
kem bhai aa x che 10 jo x > 5 { aa msg che "x is big" // block-scoped bhai bol msg // works } // bhai bol msg <-- would error here aavjo bhai