File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 8
8
reduced in size in many cases.
9
9
([ Surya Rose] ( https://github.com/GearsDatapacks ) )
10
10
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
+
11
43
### Build tool
12
44
13
45
### Language server
You can’t perform that action at this time.
0 commit comments