Documentation menu

Core Language

Variables & Types

A variable is a named box that remembers something. Put a value in the box with =. MAKO can remember numbers, words, yes/no values, nothing, lists, dictionaries, and functions.

New to coding?

Copy the examples exactly first. Run them. Then change one number or word and run them again. You are not expected to memorize the command lists.

1

Named boxes

The name goes on the left. The value goes on the right. Text uses quote marks. true and false mean yes and no. none means there is no value.

Try this code
count = 10;
name = "Robin";
alive = true;
nothing = none;
items = [1, "two", 3.5];
2

A box that cannot change

const creates an immutable binding — top-level or inside any block. Reassigning one is a runtime error with a clear message.

Try this code
const MAX_LIVES = 3;
const GRAVITY = 9.81;

GRAVITY = 10;   // error: cannot reassign const 'GRAVITY'
3

Compound assignment

These shortcuts change a number without writing its name twice.

Try this code
x += 5;
x -= 2;
x *= 3;
x /= 4;
y = -x;
4

What counts as yes?

An if asks a yes-or-no question. false, 0, empty text, empty lists, empty dictionaries, and none count as no. Other values count as yes.

Try this code
if 0 { print "never"; }
if "" { print "never"; }
if [] { print "never"; }
if -1 { print "yes, truthy"; }
5

Ask what kind of value it is

type(value) tells you the value's kind. This is useful when you are confused about what a variable holds.

Try this code
type(42)        // "number"
type("hi")      // "string"
type(true)      // "bool"
type(none)      // "none"
type([1,2])     // "list"
type({"a":1})   // "dict"
type(fn(x)=>x)  // "fn"