Skip to content

Commit 1d7e6d4

Browse files
Changelog
1 parent 2f4c885 commit 1d7e6d4

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

CHANGELOG.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,38 @@
88
reduced in size in many cases.
99
([Surya Rose](https://github.com/GearsDatapacks))
1010

11+
- The compiler now performs function inlining optimisations for a specific set
12+
of standard library functions, which can allow functions which were previously
13+
not tail-recursive on the JavaScript target to become tail-recursive. For
14+
example, the following code:
15+
16+
```gleam
17+
pub fn count(from: Int, to: Int) -> Int {
18+
use <- bool.guard(when: from >= to, return: from)
19+
io.println(int.to_string())
20+
count(from + 1, to)
21+
}
22+
```
23+
24+
Would previously cause a stack overflow on the JavaScript target for large
25+
value. Now it is rewritten to:
26+
27+
```gleam
28+
pub fn count(from: Int, to: Int) -> Int {
29+
case from >= to {
30+
True -> from
31+
False -> {
32+
io.println(int.to_string())
33+
count(from + 1, to)
34+
}
35+
}
36+
}
37+
```
38+
39+
Which allows tail-call optimisation to occur.
40+
41+
([Surya Rose](https://github.com/GearsDatapacks))
42+
1143
### Build tool
1244

1345
### Language server

0 commit comments

Comments
 (0)