Skip to content

Commit 7044fd1

Browse files
committed
added iterator into prelude
1 parent fe39406 commit 7044fd1

File tree

3 files changed

+29
-24
lines changed

3 files changed

+29
-24
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ print(vecs)
1616

1717
### Bugs
1818

19-
- struct access is still random
19+
- struct constructor is still random
2020
- print function calls just aren't executing
2121

2222
### Non functional features

example/test.gila

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,16 @@
55
std = import std
66
p = std.io.print
77

8-
Iterator type
9-
counter: u32
10-
limit: u32
11-
end
12-
13-
__iter fn(self: Iterator)
14-
// self.counter = self.counter + 1
15-
end
16-
178
i = Iterator(0,10)
18-
// i.__iter()
19-
20-
21-
// why is this print not working!!!
22-
23-
std.io.print(i.counter)
9+
res = i.__iter()
10+
res = i.__iter()
11+
res = i.__iter()
12+
res = i.__iter()
13+
res = i.__iter()
14+
res = i.__iter()
15+
res = i.__iter()
16+
res = i.__iter()
17+
res = i.__iter()
18+
res = i.__iter()
19+
20+
std.io.print(res)

prelude/prelude.gila

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,25 @@ Error type
33
msg: string
44
end
55

6-
7-
// Result = type $T | Error end
8-
9-
Result type
10-
is_ok: bool
11-
end
12-
13-
146
// what this gets compiled to is
157
// __result = my_fn()
168
// if !__result.is_ok
179
// return __result
1810
// end
1911
// r = __result.data
12+
//
13+
// Eventually we may want an algebraic data type like so
14+
// Result = type $T | Error end
15+
Result type
16+
is_ok: bool
17+
end
18+
19+
Iterator type
20+
counter: u32
21+
limit: u32
22+
end
23+
24+
__iter fn(self: Iterator) -> bool
25+
self.counter = self.counter + 1
26+
return self.counter == self.limit
27+
end

0 commit comments

Comments
 (0)