LANGUAGE CONTRACT · 13.5.0
Compile-time programming
DBYTE 13.5.0 supports bounded for loops and pure local function declarations inside comptime. The evaluator has deterministic budgets and explicitly disallows ambient host access.
Bounded for loops
Inside comptime, the supported iterable is exactly range(start, end). The end is exclusive, the step is +1, and the bounds are compile-time integers. The index is scoped to the loop.
comptime {
let total: int = 0
for index in range(0, 7):
total = total + 6
if total == 42:
emit_source("pub fn answer() -> i32:\n return " + str(total) + "\n")
else:
emit_source("pub fn answer() -> i32:\n return 0\n")
}
pub fn main() -> i32:
return answer()
Source: examples/ctfe_for_range_v135.dby. Invalid argument counts or types, unsupported iterators, or excessive ranges are rejected with E_CTFE_* diagnostics.
Pure local functions
Declare fn directly inside a top-level comptime block. Signatures require explicit int, i64, bool or str parameter/return types. Forward references and bounded recursion are permitted. Pure function bodies admit local declarations, assignments, Boolean if/else and return, but not arbitrary I/O, host calls or loops.
comptime {
fn factorial(n: int) -> int:
if n <= 1:
return 1
else:
return n * factorial(n - 1)
let answer: int = factorial(4) + 18
emit_source("pub fn answer() -> i32:\n return " + str(answer) + "\n")
}
pub fn main() -> i32:
return answer()
Source: examples/ctfe_pure_fn_v135.dby, verified as a native executable with exit code 42.
Resource limits
| Resource | Limit |
|---|---|
| Shared evaluation fuel | 1,000,000 steps |
| Nested pure function calls | 32 active frames; 33 rejected |
| Parameters per function | 16 |
| Local function declarations per block | 128 |
| Cumulative strings | 8 MiB |
| Generated source | 1 MiB |
Nested-call overflow reports E_CTFE_RECURSION; exhausted shared fuel reports E_CTFE_FUEL. Compile-time functions cannot access the filesystem, processes, network, clock or environment.
Verification and scope
The release verification includes positive native examples, forward references, boundary-depth tests and negative fail-closed cases on Windows and Debian WSL. This is software evidence, not physical BIOSTAR qualification or proof that the full compiler is self-hosted.