T ↦ P ≡ {K₁ V₁ K₂ V₂ …} ↦ {K₁ P₁ K₂ P₂ … CAPTURE?}
syntaxDestructure table T
.
Destructure Vᵢ
to Pᵢ
for every equal Kᵢ
.
If Kᵢ
is :
, interpret it as key "Pᵢ"
literally.
If Kᵢ
stars with ?
, also match nil
.
If CAPTURE
is &as T*
, set T*
to T
.
Gotcha: {}
matches any table, not the empty table.
T ↦ P ≡ [V₁ V₂ … Vₙ] ↦ [P₁ P₂ … Pₘ CAPTURE?]
syntaxDestructure a sequence from table T
.
Destructure Vᵢ
to Pᵢ
for every i ≤ m
.
If CAPTURE
is &as T*
, set T*
to T
.
If CAPTURE
is & T*
, set T*
to [Tₙ₊₁ … Tₘ]
.
Gotcha: []
matches any table, not the empty table.
V ↦ P ≡ (values V₁ V₂ … Vₙ) ↦ (P₁ P₂ … Pₘ)
syntaxDestructure multiple values.
Destructure Pᵢ
to Vᵢ
for every i ≤ m
.
Gotcha: Multiple values cannot be nested.
X ↦ E
base case syntaxIf E
is literal, check X = E
.
If E
is identifier, bind E
to X
(†).
(†) If not documented otherwise, such as in match
.
X ↦ _
conventionIgnore E
.
Also _E
for any E
.