mutable decl syntax change

This commit is contained in:
2026-08-05 21:19:41 +02:00
parent 88b94197c9
commit 081a3fd5df
74 changed files with 870 additions and 733 deletions
@@ -6,10 +6,10 @@ observe func(counter @mut i32, value ?i32) ?i32 {
}
main func() i32 {
total i32 = 0
total i32 := 0
# present optional scalar -> binds v to the unwrapped value
a ?i32 = 40
a ?i32 := 40
if a |v| {
total = total + v # 40
} else {
@@ -17,7 +17,7 @@ main func() i32 {
}
# null -> else branch taken; the binding is not in scope there
b ?i32 = null
b ?i32 := null
if b |v| {
total = total + v
} else {
@@ -25,20 +25,20 @@ main func() i32 {
}
# optional pointer present -> binds q to a non-null @i32; deref proves it
n i32 = 0
p ?@i32 = &n
n i32 := 0
p ?@i32 := &n
if p |q| {
total = total + q^ # +0
}
# optional pointer null -> skipped
z ?@i32 = null
z ?@i32 := null
if z |_| {
total = total + 1000
}
# guarded multi-unwrap exposes every capture to the guard and then-block
age ?i32 = 2
age ?i32 := 2
if a and age |value, years : value + years == 42| {
total = total
} else {
@@ -46,7 +46,7 @@ main func() i32 {
}
# parenthesized chains and three-value unwraps are equivalent
bonus ?i32 = 0
bonus ?i32 := 0
if (a and age and bonus) |value, years, extra : value + years + extra == 42| {
total = total
} else {
@@ -64,7 +64,7 @@ main func() i32 {
}
# a failed unwrap prevents later expressions from being evaluated
calls i32 = 0
calls i32 := 0
if b and observe(&calls, age) |missing, observed| {
total = total + missing + observed
}