Tekst
Source
Documentation/Pointers & Memorysource tree
Language

Pointers & Memory

Tekst exposes an explicit low-level memory layer for programs that need direct access to memory.

References to variables

pointers.tk
x = 41
p = &x
*p = 42
print(*p)

&x creates a pointer to a variable slot. *p dereferences the pointer for reading or writing.

Heap allocation

memory.tk
mem = alloc(8)
store_int(mem, 123456)
print(load_int(mem))
free(mem)

alloc(n) allocates n bytes and free(p) releases the allocation.

Memory access

Use load_int and store_int for 64-bit integers, and load_byte and store_byte for bytes.

Pointer arithmetic

pointer-arithmetic.tk
mem = alloc(8)
q = mem + 4
store_int(q, 99)
print(load_int(q))
free(mem)

Pointer arithmetic is byte-based. The native runtime checks bounds for allocated blocks.

When to use it

Use explicit memory operations when you need low-level control. For ordinary application code, prefer normal values, collections, and objects.