docs
Language Structure
Variables

Intro

Variables are Containers for Storing Data

Kin Variables can be declared in 2 ways:

reka

By declaring variables by using reka keyword, you can change the value of the variable later in the program.

reka x = value

Variable x is declared and assigned a value of value but the value can be changed later in the program.

Also, you can declare a variable without assigning a value to it.

reka x;

In this case, the variable x is declared but not assigned a value. Note: You have to add semicolon (;) at the end of the statement.

ntahinduka

By declaring variable by using ntahinduka keyword, you can't change the value of the variable later in the program.

ntahinduka x = 10

You can't change the value of variable x later in the program.

Note: You have to assign a value to a constant variable, so this won't work:

ntahinduka x; # This will throw an error

Optional type annotations

You can attach a type annotation after the variable name. Types are tokenized, parsed, and kept on the AST — they are not stripped. When a binding is annotated, Kin checks the value at declaration and on every later assignment.

reka age: umubare = 25
reka name: ijambo = "Keza"
ntahinduka PI: umubare = 3.14

A mismatch raises a clear type error:

reka name: ijambo = 42
# Cannot assign a umubare to a ijambo, expected a ijambo instead.

Unannotated bindings stay dynamic (you may reassign different kinds of values).

Required vs optional types

FormMeaning
: typeRequired — value must match the type; ubusa is rejected
: type?Optional — value may be the type or ubusa
reka score: umubare = 10     # required number
reka maybe: umubare? = ubusa # optional number (null allowed)
reka later: ijambo?;         # optional string, starts as ubusa

Annotation type names

Built-in names (Kinyarwanda):

NameMeaning
umubarenumber
ijambostring
ukuriboolean
ubwoko_imiterereplain object
urutondearray
porogaramu_ntoyafunction (user or native)
_porogaramu_ntoyanative function (synonym of the above for annotations)
ubusanull

You can also use named type aliases declared with ubwoko (object shapes, unions, Fata). See Data Types.

reka list: urutonde = [1, 2, 3]
reka print: porogaramu_ntoya = tangaza_amakuru

Built-in names

Kin also provides two globals you do not declare:

  • filename — a string: the path of the running .kin file. KIN_INYANDIKO resolves relative paths against its directory.
  • ikosa — a mutable name, initially ubusa. Reserved as an error holder; the runtime does not currently write to it automatically.