Variables & Types

Bindings

Tape has two binding forms:

tape
let x: i64 = 42;    // immutable — cannot be reassigned
var y: i64 = 0;     // mutable — can be reassigned

Use let by default. Use var when you need to reassign.

Types

See Primitive Types for the full list of built-in types (i8i64, u8u64, f32, f64, bool, string, color, void).

Example

tape
@profile(t1);
import io from "io";

pub fn main() -> i32 {
    let x: i64 = 42;
    var y: i64 = 0;
    y = y + x;
    io.print_i64(y);
    io.print("\n");
    return 0;
}

Constants

Compile-time constants use const:

tape
const MAX_SIZE: i64 = 1024;
const PI: f64 = 3.14159265358979;

Constants are evaluated at compile time and inlined at usage sites.

Type inference

When an initializer is present, the type annotation can be omitted:

tape
let x = 42;          // inferred as i64
var name = "tape";   // inferred as string

Without an initializer, a type annotation is required.

Last modified: