Skip to main content

Low-level and compile-time syntax

This page covers the syntax Draton exposes for low-level escape hatches and compile-time control.

Unsafe block

@unsafe {
let x = 1 + 2
}

Pointer block

@pointer {
let x = 1
}

This is the surface escape hatch for pointer-oriented code regions.

Compile-time block

@comptime {
let size = 4 * 1024
}

Inline assembly block

@asm { mov eax, 1 }

The parser currently treats the inside of @asm { ... } as raw token text joined back together into one assembly string.

Compile-time conditional

@if condition {
print("enabled")
}

This is a statement form, not the same thing as ordinary runtime if.

GC configuration block

@gc_config {
threshold: 1024
young_size: 4096
}

The parser accepts a brace-delimited list of key: expr entries.

Extern declarations

Extern blocks are the top-level syntax for binding external functions:

@extern "C" {
fn malloc(size: UInt64) -> @pointer
fn free(ptr: @pointer)
}

Special runtime handlers

The parser recognizes two special top-level handler items:

@panic_handler
fn on_panic(msg) { }

@oom_handler
fn on_oom() { }

Use these only when working at the runtime boundary.