Matchbox 0.2

Types

Matchbox is statically typed: every expression, variable, parameter, and return value has a type known by the compiler before the program runs. Matchbox 0.2 provides one source-language type: int.

var answer int = 42

An int is a signed 32-bit integer with a range of -2,147,483,648 through 2,147,483,647. Matchbox does not provide floating-point, Boolean, character, string, collection, or user-defined types in this release.

Static types let Matchbox check more of a program while compiling it. Because the compiler knows each value's type ahead of time, it can reject mismatched declarations, function calls, and assignments before bytecode runs. Compile-time type information also makes storage layout and generated instructions predictable, which helps diagnostics stay precise and gives the VM less guesswork to do at runtime.

When an initial value is present, the annotation can be omitted:

var answer = 42

Function parameter and return annotations can also be omitted; they default to int.

Comparison and logical expressions are not supported in 0.2. The unary ! operator still produces the integer 1 or 0.