Development · Evolving reference
Compile-time execution
Compute values before the program runs.
Sn is under heavy development. This reference includes the intended 1.0 design; features may be incomplete in the current compiler. Read the status →
Constants
const MaxPlayers: usize = 64;A constant declaration requires compile-time evaluation and an explicit type.
Dual-stage functions
const fn Double(Value: i32) -> i32 {
return Value * 2;
}
const Answer: i32 = Double(21);const fn is dual-stage: it can execute at compile time under the documented rules, or as an ordinary runtime call for runtime input.
Required compile-time calls
consteval fn requires every call to execute during compilation. Passing runtime-only input is an error.
Explicit forcing
const Expression explicitly requires compile-time evaluation. Array extents, enum discriminants, const-generic arguments, and typed attribute construction also require constant evaluation.
Restricted execution
Compile-time execution does not grant arbitrary I/O, environment access, allocation, FFI, or declaration-generation privileges. It is a bounded language facility, not a general build-script escape hatch.
Documentation snapshot: October 24, 2026 About versions ↗