SplitScript reference / Language / binding pattern
binding pattern
syntax
let Pattern = value | fn name(Pattern: Type) | for Pattern in values
Destructures one value into local names where a declaration cannot fail.
Initialized let declarations, named fn parameters, parenthesized closure parameters, and runtime for bindings accept the same recursive struct, enum, wrapper, array, wildcard, and alternative pattern grammar as match and is. The incoming initializer, argument, or iterator item is evaluated exactly once and remains one ABI value; each binding leaf receives its projected type. A type annotation after the pattern constrains the complete incoming value, not an individual leaf. When that context already identifies one concrete struct, { field, other: pattern } may omit its nominal type name; Name { ... } remains available explicitly and field names alone never infer a structural type. Such a pattern must be irrefutable: it must cover every value its type can actually contain. Never is uninhabited recursively, so an enum variant carrying Never, a struct containing it, or a nonempty fixed array of it cannot occur and need not be covered. For an ordinary optional or multi-variant value, use is to test one case or an exhaustive match instead. Uninitialized attachment- and attempt-scoped globals deliberately remain single names because lifecycle code initializes their storage later.
Examples
Destructure a struct once
let { x, y }: Point = point
Destructure parameters and iterator items
fn sum({ x, y }: Point) -> u32 {
return x + y
}
for { x, y: _ } in points {
print(x)
}