LEGACY DOCS · 12.0Stable is 13.2. This page stays because it still owns historical or unchanged contracts.CURRENT 13.2 →
RELEASE LINE13.2 STABLE13.1 PREDECESSOR13.0 PREVIOUS12.4 NATIVE MIRARCHIVE

V12.0 BASE CONTRACT

Pointers

ptr[T] is mutable and nullable; const_ptr[T] is read-only and nullable. Arithmetic scales by pointee layout.

DByte 12.0 · Language

Contract§

pub struct Counter:
    value: u32

fn increment(counter: ptr[Counter]) -> int:
    (*counter).value = (*counter).value + (1 as u32)
    return 0

pub fn kernel_main() -> int:
    let counter = Counter(value = 41 as u32)
    increment(&counter)
    if counter.value != (42 as u32):
        return 1
    return 0

Source: source-examples/v12.0.0/pointers.dby

pointers.dbyDOWNLOADOPEN RAW
pub struct Counter:
    value: u32

fn increment(counter: ptr[Counter]) -> int:
    (*counter).value = (*counter).value + (1 as u32)
    return 0

pub fn kernel_main() -> int:
    let counter = Counter(value = 41 as u32)
    increment(&counter)
    if counter.value != (42 as u32):
        return 1
    return 0
DBY · 312 BSHA-256 596a478005ac991c0106ac47d1ac78fea50f72065a074cff5be97dbfd9cf6db3

Mechanics§

ptr[T] is mutable nullable raw storage; const_ptr[T] is read-only nullable raw storage. Arithmetic scales by pointee layout, with ptr[u8] reserved for byte addressing; dereference plus field projection remains a typed place.

Validation and failure§

Integer-pointer casts are explicit and pass through usize. Reverse const-to-mutable conversion, unknown fields, wrong pointee aggregates and immutable global stores are rejected.

Evidence and boundary§

Typed field-address IR and width-correct load/store disassembly prove that source-level pointer fields do not become ad hoc byte offsets.

Executable example§

pub struct Counter:
    value: u32

fn increment(counter: ptr[Counter]) -> int:
    (*counter).value = (*counter).value + (1 as u32)
    return 0

pub fn kernel_main() -> int:
    let counter = Counter(value = 41 as u32)
    increment(&counter)
    if counter.value != (42 as u32):
        return 1
    return 0

WEBSITE V12 FIXTURE