"Fix" examples and add TODOs for later syntax

This commit is contained in:
mars 2022-03-03 20:26:45 -07:00
parent 9c1709e134
commit 01bb85d386
2 changed files with 19 additions and 14 deletions

View File

@ -4,11 +4,12 @@ interface Update {
}
struct Clock12Hr {
bool pm = true,
u8 hours = 12,
u8 minutes = 0,
u8 seconds = 0,
f64 sub = 0.0,
// TODO structure member initialization expressions
bool pm, // = true,
u8 hours, // = 12,
u8 minutes, // = 0,
u8 seconds, // = 0,
f64 sub, // = 0.0,
}
impl Clock12Hr {
@ -32,8 +33,10 @@ impl Clock12Hr {
.hours = .hours + 1;
if .hours >= 13 {
.hours = 1;
} else if hours == 12 {
.hours = not .hours;
} else { // TODO else-if statements
if hours == 12 {
.pm = not .pm;
}
}
}
}

View File

@ -7,11 +7,11 @@ struct World {
u32 numdots,
BitArray next,
// members can have default initialization values
i32 xmin = 1'000'000,
i32 xmax = -1,
i32 ymin = 1'000'000,
i32 ymax = -1,
// TODO member default initialization
i32 xmin, // = 1'000'000,
i32 xmax, // = -1,
i32 ymin, // = 1'000'000,
i32 ymax, // = -1,
}
// non-associated function, operates in the scope of its arguments only
@ -47,7 +47,8 @@ World mut fn set_next(i32 i, i32 j) {
if neighbors != 3 {
0
} else {
numdots++;
// TODO binary operator assignment shorthand
numdots = numdots + 1;
1
}
} else {
@ -55,7 +56,8 @@ World mut fn set_next(i32 i, i32 j) {
if neighbors == 2 or neighbors == 3 {
1
} else {
numdots--;
// TODO binary operator assignment shorthand
numdots = numdots - 1;
0
}
};