4.1 Variables and constants
| Form | Semantics |
|---|---|
let x = e | immutable binding |
var x = e | mutable binding |
let x: T = e | with an explicit type |
const NAME: T = e | the value is evaluated at compile time; e MUST be a comptime expression; allowed at module level and inside functions |
static NAME: T = e | a module-level global value; initialised once on first access, thread-safe; T MUST be frozen or sync |
- There are no mutable globals without
sync. letMAY shadow a name in a nested and in the same scope.- Destructuring:
let (a, b) = pair,let User{ name, .. } = u.
Related diagnostics
global-mutable, mutate-immutable
See also
Source: docs/spec/oxl-standard.en.md