Variable Declaration

Variables are declared with the var keyword, optionally initialised, and optionally annotated with a type hint.

var count = 0                     # Initialised
var name = "Alice"
var unset                         # Defaults to null
var items: array = [1, 2, 3]     # With type hint
var label: string = 42            # Coerced to "42"

A variable that is declared without an initialiser has the value null.

Type Hints

Optional type annotations may follow the variable name, separated by a colon. When a type hint is present, the assigned value is coerced to that type:

var name: type = value

Valid type keywords: number, string, boolean, array, object.

Coercion Rules

Target Type From Number From String From Boolean
number (no change) Parsed as number true1, false0
string String representation (no change) "true" or "false"
boolean 0false, else true "true"true, "false"false only (no change)

For array and object type hints, there is no cross-type coercion - the value must already be of the matching type. Assigning a non-matching type to an array or object hint results in an error.


Back to top

Copyright © Mesch Systems 2025-2026. All rights reserved.