2. Values and operators
This lesson is verified against Zryna 0.2.1 from 841c8aee901782c9f7bf442bfe8eb2fe6b7f6446. The exact operator semantics live in the release’s M2_JAVASCRIPT_BACKEND.md and matching WebAssembly backend.
Open tutorial-control/src/scalars.zry:
export function calculate(start: i32, step: i32): i32 { let total: i32 = start; const doubled: i32 = step * 2; total = total + doubled; return total - 1;}
export function isAtLeast(left: i32, right: i32): bool { return left >= right;}Types and bindings
Section titled “Types and bindings”i32is a signed 32-bit integer. Published arithmetic wraps to its low 32 bits.boolhas exactlytrueandfalse; numeric truthiness is not accepted.constcreates an initialized binding that cannot be assigned again.letcreates an initialized mutable binding. Assignment must keep the exact type.
The published scalar operators are unary -, integer +, -, *, signed <, <=, >, >=, and exact === and !== for equal scalar types. This preview does not admit division, remainder, coercing equality, or untyped numbers in this profile.
Run a Boolean export
Section titled “Run a Boolean export”& $zryna run src/scalars.zry ` --project-root "$workspace\tutorial-control" ` --profile control-flow-v1 ` --target javascript ` --name comparison-1 ` --export isAtLeast ` --arg=i32:9 ` --arg=i32:4Expected output:
javascript: bool trueTyped arguments are strict. Use canonical forms such as i32:-1, i32:0, and bool:false; 01, +1, fractions, and True are rejected.
Common errors
Section titled “Common errors”- Assigning to
constis rejected. Useletonly when the algorithm needs reassignment. - Assigning a
boolto ani32(or the reverse) is an exact-type error; there is no implicit conversion. - Arithmetic overflow wraps for
i32; it does not widen to a JavaScript number.
Exercise
Section titled “Exercise”Run isAtLeast on both targets with left = -3 and right = 2. Then run it with equal values. Use new output names for every run.