Skip to main content

Primitives

mType has four built-in primitive types and a generic single-slot container.

Lowercase (raw)Wrapper classNotes
intInt64-bit signed integer
floatFloat64-bit IEEE float
boolBooltrue / false
stringStringUTF-8 string, interned in the string pool
Box<T>Generic single-slot container

The lowercase forms (int, float, bool, string) are the raw primitives. The capitalized wrappers (Int, Float, Bool, String) are object types that flow through generic containers and Object-typed APIs.

Literals

int n = 42;
float pi = 3.14;
bool ok = true;
string greet = "Hello";

Hex literals are written 0x.... Floats accept exponent notation: 1.5e3.

Wrappers

import * from "lib/primitives/Int.mt";

Int boxed = new Int(42);
print(boxed.getValue()); // 42
print(boxed.compareTo(new Int(10))); // 1 (greater)

Int, Float, and Bool provide getValue(), comparison, and arithmetic methods. Bool adds and, or, xor, not. Float adds lessThan, greaterThan, and toInt.

Box<T>

A generic single-slot holder for any type:

import * from "lib/primitives/Box.mt";

Box<string> name = new Box<string>("World");
name.set("mType");
print(name.get()); // mType

Useful when you need to pass a primitive by reference into a closure or generic API.

Conversion

From → ToHow
intfloatImplicit widening on int → float; explicit (int) f for the reverse.
intIntnew Int(n).
Intintboxed.getValue().
anything → stringstring interpolation $"{value}" or + concatenation.

See Standard Library / Primitives for full method lists.