You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _blogposts/2020-02-09-release-9-0.mdx
+19-19Lines changed: 19 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,7 @@ date: "2020-02-09"
4
4
previewImg:
5
5
category: compiler
6
6
title: ReScript 9.0
7
+
badge: release
7
8
description: |
8
9
---
9
10
@@ -42,10 +43,10 @@ is indeed a problem for you.
42
43
43
44
### Zero-cost bundle size when adding ReScript
44
45
45
-
We keep generating code that is friendly for tree-shaking during each releases.
46
-
We believe we reach a milestone that ReScript adds close to zero cost to your bundler
47
-
size unlike many other programming languages compiled into JS; the bundled code is almost ReScript runtime free and
48
-
the generated library code is fits the tree-shaking principle very well.
46
+
With each release, we keep a close eye on generating code that is optimized for tree-shaking.
47
+
We believe we reached a milestone that ReScript adds close to zero cost to your bundle-size.
48
+
Unlike many other programming languages compiled into JS, the bundled code is almost ReScript runtime free and
49
+
the generated library code fits the tree-shaking principle very well.
49
50
50
51
To demonstrate what we achieved, we made a [repo](https://github.com/bobzhang/zero-cost-rescript) so that
51
52
you can try it and see how good the bundled code is.
@@ -55,7 +56,7 @@ you can try it and see how good the bundled code is.
55
56
56
57
We continue improving the quality of generated code in this release.
57
58
58
-
Take this [issue](https://github.com/rescript-lang/rescript-compiler/issues/4924) for example, for pattern match as below:
59
+
Take this [issue](https://github.com/rescript-lang/rescript-compiler/issues/4924) for example:
59
60
60
61
```res
61
62
let test = x =>
@@ -65,7 +66,7 @@ let test = x =>
65
66
}
66
67
```
67
68
68
-
It used to generate code as below:
69
+
It used to generate the following code:
69
70
70
71
```js
71
72
functiontest(x) {
@@ -77,19 +78,18 @@ function test(x) {
77
78
}
78
79
79
80
```
80
-
Now it is simplified as
81
+
which now gets optimized to:
81
82
```js
82
83
functiontest(x){
83
84
return x ===0
84
85
}
85
86
```
86
87
87
-
This is possible is that our optimizer will try to analyze several predicates and get rid of redundant predicates,
88
-
more diffs could be found [here](https://github.com/rescript-lang/rescript-compiler/pull/4927/files?file-filters%5B%5D=.js).
88
+
This is possible because our optimizer will try to analyze several predicates and get rid of redundant ones.
89
+
More diffs can be found [here](https://github.com/rescript-lang/rescript-compiler/pull/4927/files?file-filters%5B%5D=.js).
89
90
90
-
Another important improvement is that we fixed the pattern match offset issue, the consequence is that
91
-
magic number will not be generated
92
-
for complex pattern matches any more, below is a represenative diff thanks to this clean up:
91
+
Another important improvement is that we fixed the pattern match offset issue, which leads to the consequence, that magic numbers will not be generated for complex pattern matches anymore.
92
+
Below is a representative diff resulting from this cleanup:
93
93
94
94
```diff
95
95
function is_space(param){
@@ -109,7 +109,7 @@ function is_space(param){
109
109
110
110
We introduced two minor tweaks for the concrete syntax.
111
111
112
-
-guard in pattern matching is recommended to use `if` instead of `when`
112
+
-It is now recommended to use `if` instead of `when` in pattern match guards
113
113
114
114
```res
115
115
switch expr {
@@ -122,13 +122,13 @@ switch expr {
122
122
- explicit nested object literal syntax
123
123
124
124
125
-
`{"keya": {keyb : 3 } }` used to be interpreted as `{"keya": {"keyb": 3 } } `, such implicity makes
126
-
us not able to embed regular records inside JS object literals. Since this release,
127
-
user has to write JS object literals explicitly and `{"keya": {keyb : 3}}` will be interpreted as a regular
128
-
record inside a js object literal. More discussions can be found [here](https://forum.rescript-lang.org/t/fixing-the-semantics-of-nested-objects-breaking-changes/976).
125
+
`{"keya": { keyb: 3 } }` used to be interpreted as `{"keya": {"keyb": 3 } } `, such implicity makes
126
+
us not able to embed regular records inside JS object literals. With this release,
127
+
JS object literals have to be written explicitly and `{"keya": { keyb: 3 } }` will be interpreted as a regular
128
+
record inside a JS object literal. More discussions can be found [here](https://forum.rescript-lang.org/t/fixing-the-semantics-of-nested-objects-breaking-changes/976).
129
129
130
130
131
-
Note there are some pretty interesting internal changes in this release -- for example, using WASM to replace Camlp4 and a
132
-
generalized visitor pattern without using objects -- that we will discuss in a separate post
131
+
There are also some pretty interesting internal changes in this release.
132
+
For example, using WASM to replace Camlp4 and a generalized visitor pattern without using objects, which we will discuss in a separate post.
0 commit comments