mutable decl syntax change
This commit is contained in:
@@ -1,31 +1,31 @@
|
||||
# Milestone 5: boolean while loops with optional post-iteration updates.
|
||||
|
||||
return_before_update func() i32 {
|
||||
i i32 = 0
|
||||
i i32 := 0
|
||||
while true : i = i + 1 {
|
||||
return i
|
||||
}
|
||||
}
|
||||
|
||||
main func() i32 {
|
||||
total i32 = 0
|
||||
total i32 := 0
|
||||
|
||||
# ordinary condition and update
|
||||
i u32 = 0
|
||||
i u32 := 0
|
||||
while i < 5 : i = i + 1 {
|
||||
total = total + 2
|
||||
}
|
||||
|
||||
# equivalent parenthesized header
|
||||
j u32 = 0
|
||||
j u32 := 0
|
||||
while (j < 4) : (j = j + 1) {
|
||||
total = total + 3
|
||||
}
|
||||
|
||||
# nested loops and body-local storage
|
||||
outer u32 = 0
|
||||
outer u32 := 0
|
||||
while outer < 2 : outer = outer + 1 {
|
||||
inner u32 = 0
|
||||
inner u32 := 0
|
||||
while inner < 3 : inner = inner + 1 {
|
||||
total = total + 2
|
||||
}
|
||||
@@ -33,9 +33,9 @@ main func() i32 {
|
||||
|
||||
# Body-local storage stays scoped to the body. The update still targets
|
||||
# the mutable k declared before the loop.
|
||||
k u32 = 0
|
||||
k u32 := 0
|
||||
while k < 4 : k = k + 1 {
|
||||
body_k u32 = 100
|
||||
body_k u32 := 100
|
||||
if body_k == 100 {
|
||||
total = total + 2
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user